-
-
Notifications
You must be signed in to change notification settings - Fork 457
Expand file tree
/
Copy pathtest_wizard.py
More file actions
25 lines (18 loc) · 1.17 KB
/
test_wizard.py
File metadata and controls
25 lines (18 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from django.template.loader import render_to_string
from django.test import SimpleTestCase
class TestWizardActionsTemplate(SimpleTestCase):
def test_render_template_authenticated(self):
template_name = 'two_factor/_wizard_actions.html'
# Render the template
rendered_template = self.render_template(template_name, {'user': {'is_authenticated': True}, 'cancel_url': '/cancel', 'wizard': {'steps': {'prev': 'previous_step'}}})
# Assert that the "Sign in" button is not present for authenticated users
self.assertNotIn('<button type="submit" name="login" class="btn btn-dark">Sign in</button>', rendered_template)
def test_render_template_not_authenticated(self):
template_name = 'two_factor/_wizard_actions.html'
# Render the template
rendered_template = self.render_template(template_name, {'user': {'is_authenticated': False}})
# Assert that the "Sign in" button is present for non-authenticated users
self.assertIn('Sign in', rendered_template)
def render_template(self, template_name, context):
# Render the template with the context
return render_to_string(template_name, context)