Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msaqib52 committed Nov 24, 2020
1 parent 5bbeb7d commit 654abe4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/unit/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,23 @@
</script>\
""".format(expected_filled_template)

expected_filled_translated_js_template = u"""\
<script type='text/template' id='example-unique-id'>
{}
</script>\
""".format(expected_translated_template)

expected_filled_not_translated_js_template = u"""\
<script type='text/template' id='example-unique-id'>
{}
</script>\
""".format(expected_not_translated_template)

expected_filled_localized_js_template = u"""\
<script type='text/template' id='example-unique-id'>
{}
</script>\
""".format(expected_localized_template)

another_template = u"""\
<explanation>This is an even simpler xml template.</explanation>
Expand Down Expand Up @@ -199,6 +216,27 @@ def test_render_js_template(self):
s = loader.render_js_template("data/simple_django_template.txt", example_id, example_context)
self.assertEqual(s, expected_filled_js_template)

def test_render_js_template_translated(self):
loader = ResourceLoader(__name__)
s = loader.render_js_template("data/trans_django_template.txt",
example_id,
context=example_context,
i18n_service=MockI18nService())
self.assertEqual(s, expected_filled_translated_js_template)

# Test that the language changes were reverted
s = loader.render_js_template("data/trans_django_template.txt", example_id, example_context)
self.assertEqual(s, expected_filled_not_translated_js_template)

def test_render_js_template_localized(self):
# Test that default template tags like l10n are loaded
loader = ResourceLoader(__name__)
s = loader.render_js_template("data/l10n_django_template.txt",
example_id,
context=example_context,
i18n_service=MockI18nService())
self.assertEqual(s, expected_filled_localized_js_template)

def test_load_scenarios(self):
loader = ResourceLoader(__name__)
scenarios = loader.load_scenarios_from_path("data")
Expand Down

0 comments on commit 654abe4

Please sign in to comment.