Skip to content

Commit

Permalink
waffle: adding template tag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewEthanTam committed Nov 18, 2024
1 parent 530b312 commit 41eedd9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions waffle/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from test_app import views
from waffle.middleware import WaffleMiddleware
from waffle.tests.base import TestCase
from waffle.testutils import override_switch, override_flag, override_sample


def get():
Expand Down Expand Up @@ -37,6 +38,26 @@ def test_django_tags(self):
self.assertContains(response, 'switch_var off')
self.assertContains(response, 'sample_var')
self.assertContains(response, 'window.waffle =')
self.assertContains(response, 'flag_is_active off')
self.assertContains(response, 'switch_is_active off')
self.assertContains(response, 'sample_is_active off')

@override_flag("flag", active=True)
@override_sample("sample", active=True)
@override_switch("switch", active=True)
def test_django_tags_enabled(self):
request = get()
response = process_request(request, views.flag_in_django)
self.assertContains(response, 'flag on')
self.assertContains(response, 'switch on')
self.assertContains(response, 'sample on')
self.assertNotContains(response, 'flag off')
self.assertNotContains(response, 'switch off')
self.assertNotContains(response, 'sample off')
self.assertContains(response, 'window.waffle =')
self.assertContains(response, 'flag_is_active on')
self.assertContains(response, 'switch_is_active on')
self.assertContains(response, 'sample_is_active on')

def test_get_nodes_by_type(self):
"""WaffleNode.get_nodes_by_type() should find all child nodes."""
Expand Down

0 comments on commit 41eedd9

Please sign in to comment.