tests for template

This commit is contained in:
Matthias 2022-05-11 22:47:41 +02:00
parent fdc6c8300a
commit da885456b7
No known key found for this signature in database
GPG Key ID: AB6D0E6C4CB65093
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,23 @@
"""Unit tests for helpers.py"""
from django.test import TestCase
from .helpers import render_template
class HelperTests(TestCase):
"""Tests for helpers"""
def test_render_template(self):
"""Check if render_template helper works"""
class ErrorSource:
slug = 'sampleplg'
# working sample
response = render_template(ErrorSource(), 'sample/sample.html', {'abc': 123} )
self.assertEqual(response, '<h1>123</h1>')
# Wrong sample
response = render_template(ErrorSource(), 'sample/wrongsample.html', {'abc': 123} )
self.assertTrue('lert alert-block alert-danger' in response)
self.assertTrue('Template file <em>sample/wrongsample.html</em>' in response)

View File

@ -0,0 +1 @@
<h1>{{abc}}</h1>