-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-falsey-raw-templatetag-values' into 'master'
Fix falsey raw values for template tags, add tests and update runtests.py to… Closes #13 See merge request mikalai.radchuk/django-pattern-library!8
- Loading branch information
Showing
7 changed files
with
68 additions
and
12 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
5 changes: 5 additions & 0 deletions
5
tests/templates/patterns/atoms/tags_test_atom/tags_test_atom.html
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,5 @@ | ||
{% load test_tags %} | ||
|
||
SAND{% error_tag empty_string %}WICH | ||
SAND{% error_tag none %}WICH | ||
SAND{% error_tag zero %}WICH |
8 changes: 8 additions & 0 deletions
8
tests/templates/patterns/atoms/tags_test_atom/tags_test_atom.yaml
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,8 @@ | ||
tags: | ||
error_tag: | ||
empty_string: | ||
raw: '' | ||
none: | ||
raw: null | ||
zero: | ||
raw: 0 |
Empty file.
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,14 @@ | ||
from django import template | ||
|
||
from pattern_library.monkey_utils import override_tag | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def error_tag(arg=None): | ||
"Just raise an exception, never do anything" | ||
raise Exception("error_tag raised an exception") | ||
|
||
|
||
override_tag(register, 'error_tag') |
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 |
---|---|---|
@@ -1,5 +1,13 @@ | ||
from django.core.urlresolvers import reverse | ||
from django.test import SimpleTestCase | ||
|
||
|
||
class TagsTesCase(SimpleTestCase): | ||
pass | ||
def test_falsey_raw_values_for_tag_output(self): | ||
response = self.client.get(reverse( | ||
'pattern_library:display_pattern', | ||
kwargs={'template_name': 'patterns/atoms/tags_test_atom/tags_test_atom.html'}, | ||
)) | ||
self.assertContains(response, "SANDWICH") | ||
self.assertContains(response, "SANDNoneWICH") | ||
self.assertContains(response, "SAND0WICH") |