-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
tests/dj_angles/mappers/thirdparty/test_map_bird_component.py
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,54 @@ | ||
from dj_angles.mappers.thirdparty import map_bird_component | ||
from tests.dj_angles.tags import create_tag | ||
|
||
|
||
def override_setting(settings, key, value): | ||
old_value = getattr(settings, key, None) | ||
setattr(settings, key, value) | ||
return old_value | ||
|
||
|
||
def restore_setting(settings, key, old_value): | ||
setattr(settings, key, old_value) | ||
|
||
|
||
def test_not_self_closing(settings): | ||
initial_setting = override_setting(settings, "default_component_mapper", "dj_angles.mappers.thirdparty.map_bird_component") | ||
assert True == True | ||
restore_setting(settings, "default_component_mapper", initial_setting) | ||
expected = "{% bird partial %}" | ||
|
||
html = "<dj-partial>" | ||
tag = create_tag(html) | ||
|
||
actual = map_bird_component(tag=tag) | ||
|
||
assert actual == expected | ||
|
||
|
||
def test_is_closing(settings): | ||
initial_setting = override_setting(settings, "default_component_mapper", "dj_angles.mappers.thirdparty.map_bird_component") | ||
|
||
expected = "{% endbird %}" | ||
|
||
html = "</dj-partial>" | ||
tag = create_tag(html) | ||
|
||
actual = map_bird_component(tag=tag) | ||
|
||
assert actual == expected | ||
restore_setting(settings, "default_component_mapper", initial_setting) | ||
|
||
|
||
def test_self_closing(settings): | ||
initial_setting = override_setting(settings, "default_component_mapper", "dj_angles.mappers.thirdparty.map_bird_component") | ||
|
||
expected = "{% bird partial / %}" | ||
|
||
html = "<dj-partial />" | ||
tag = create_tag(html) | ||
|
||
actual = map_bird_component(tag=tag) | ||
|
||
assert actual == expected | ||
restore_setting(settings, "default_component_mapper", initial_setting) |