From f54ba5fdba9188e43250fd1be232b666449d1aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Sat, 19 Jul 2014 19:40:58 -0600 Subject: [PATCH] Adding tests for _unescape_entities and _encode_escape_chars. --- test_secretary.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test_secretary.py b/test_secretary.py index ada8864..452c815 100644 --- a/test_secretary.py +++ b/test_secretary.py @@ -28,6 +28,35 @@ class RenderTestCase(TestCase): self.engine = Renderer() self.engine.render(template) + def test__unescape_entities(self): + test_samples = { + '{{ "greater_than_1" if 1>0 }}': '{{ "greater_than_1" if 1>0 }}', + '{{ "lower_than_1" if 1<0 }}': '{{ "lower_than_1" if 1<0 }}', + '{{ if multiple_spaces }}': '{{ if multiple_spaces }}', + '{{ if multiple_spaces }}': '{{ if multiple_spaces }}', + '{{ if multiple_spaces }}': '{{ if multiple_spaces }}', + } + + for test, expect in test_samples.iteritems(): + assert self.engine._unescape_entities(test) == expect + + def test__encode_escape_chars(self): + test_samples = { + # r'(.*) + '\n': '', + '\n': '', + '\n': '', + '\n': '', + '\u0009': '', + '\n': '', + '\u0009': '', + '\u000d': '', + '\u000a': '', + } + + for test, expect in test_samples.iteritems(): + assert self.engine._encode_escape_chars(test) == expect + def test_create_test_node(self): assert self.engine.create_text_node(self.document, 'text').toxml() == 'text'