-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(forum) wrap iframe in div tag, for display purpose
- Loading branch information
1 parent
d5d52c2
commit 158ac51
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest # noqa | ||
|
||
from lacommunaute.forum.forms import wrap_iframe_in_div_tag | ||
|
||
from lacommunaute.forum.forms import ForumForm | ||
from lacommunaute.forum.models import Forum | ||
|
||
|
||
def test_wrap_iframe_in_div_tag(): | ||
inputs = [ | ||
"<iframe src='xxx'></iframe>", | ||
"<div><iframe src='yyy'></iframe></div>", | ||
"<div><iframe src='zzz'></iframe>", | ||
"<iframe src='www'></iframe></div>", | ||
] | ||
outputs = [ | ||
"<div><iframe src='xxx'></iframe></div>", | ||
"<div><iframe src='yyy'></iframe></div>", | ||
"<div><iframe src='zzz'></iframe>", | ||
"<iframe src='www'></iframe></div>", | ||
] | ||
assert wrap_iframe_in_div_tag(" ".join(inputs)) == " ".join(outputs) | ||
|
||
|
||
def test_saved_forum_description(db): | ||
form = ForumForm( | ||
data={ | ||
"name": "test", | ||
"short_description": "test", | ||
"description": "Text\n<iframe src='xxx'></iframe>\ntext\n<div><iframe src='yyy'></iframe></div>\nbye", | ||
} | ||
) | ||
assert form.is_valid() | ||
form.instance.type = Forum.FORUM_POST | ||
forum = form.save() | ||
assert forum.description.rendered == ( | ||
"<p>Text</p>\n\n<div><iframe src='xxx'></iframe></div>\n\n" | ||
"<p>text</p>\n\n<div><iframe src='yyy'></iframe></div>\n\n<p>bye</p>" | ||
) |