-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block templatetag render test; skeleton for more tests; fixes to last…
… commit (missing context from _resolve_expressions)
- Loading branch information
Showing
4 changed files
with
107 additions
and
9 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
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,52 @@ | ||
from django.contrib.sessions.middleware import SessionMiddleware | ||
from wagtail import blocks | ||
|
||
from wagtail_fedit.templatetags import ( | ||
fedit as templatetags, | ||
) | ||
from wagtail_fedit import ( | ||
utils, | ||
) | ||
from .base import ( | ||
BaseFEditTest, | ||
) | ||
|
||
class TestBlockTemplateTag(BaseFEditTest): | ||
|
||
def test_render_regular(self): | ||
|
||
block, contentpath = utils.find_block("a98a19c6-2ead-4e69-9ea2-3158c7e82976", self.basic_model.content) | ||
self.assertEqual(block.value["link"]["text"], "Test Item 3") | ||
self.assertEqual(contentpath, ["3e9144fd-5fa5-47f8-917e-8fe87c15da01", "items", "a98a19c6-2ead-4e69-9ea2-3158c7e82976"]) | ||
|
||
item = self.basic_model.content.stream_block.get_block_by_content_path(self.basic_model.content, contentpath) | ||
self.assertEqual(item.value["link"]["text"], "Test Item 3") | ||
|
||
# Setup user attribute for request. | ||
request = self.request_factory.get("/") | ||
request.user = self.admin_user | ||
|
||
context = { | ||
"request": request, | ||
"model": self.basic_model, | ||
"block": block, | ||
} | ||
|
||
node = templatetags.BlockEditNode( | ||
nodelist=None, | ||
block=block, | ||
block_id="a98a19c6-2ead-4e69-9ea2-3158c7e82976", | ||
field_name="content", | ||
model=self.basic_model, | ||
) | ||
|
||
self.assertHTMLEqual( | ||
node.render(context), | ||
block.render(context) | ||
) | ||
|
||
|
||
|
||
|
||
|
||
|
Empty file.