aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-03-07 10:34:06 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-03-07 10:34:06 +0100
commitb777a731f172cd06d1e1311ec681b72e9ed14717 (patch)
tree795102b42b3e925902f713a36b092cbf9a2944c6 /tests
parent385494c666561ddc1b95d35d6c0ce0395ff95e12 (diff)
New custom filter for templates: to_yaml.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_templating.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_templating.py b/tests/test_templating.py
new file mode 100644
index 0000000..33889ae
--- /dev/null
+++ b/tests/test_templating.py
@@ -0,0 +1,42 @@
+import decimal
+import unittest
+
+from lesana import templating
+
+
+class testFilters(unittest.TestCase):
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def test_to_yaml(self):
+ res = templating.to_yaml(None)
+ self.assertIsInstance(res, str)
+ self.assertEqual(res, 'null')
+
+ s = "A short string"
+ res = templating.to_yaml(s)
+ self.assertEqual(res, s)
+
+ s = """
+ A long, multiline
+ string
+ with multiple
+ lines
+ """
+ res = templating.to_yaml(s)
+ self.assertIsInstance(res, str)
+ self.assertIn('"', res)
+ self.assertIn('\n', res)
+
+ res = templating.to_yaml(10)
+ self.assertEqual(res, '10')
+
+ res = templating.to_yaml(decimal.Decimal('10.1'))
+ self.assertEqual(res, "'10.1'")
+
+
+if __name__ == '__main__':
+ unittest.main()