diff options
author | jelle van der Waa <jelle@vdwaa.nl> | 2018-01-22 18:41:39 +0100 |
---|---|---|
committer | Angel Velásquez <angvp@archlinux.org> | 2018-01-22 12:41:39 -0500 |
commit | f42f357fdf20d76bc5468ec227dac66cd0ca3ca8 (patch) | |
tree | 3603d73e12c84cf5513cef7ac8a2041289d34159 /mirrors/tests/test_templatetags.py | |
parent | c79dc7dcf4a13e381a59a63c57590f2272aa0869 (diff) | |
download | archweb-f42f357fdf20d76bc5468ec227dac66cd0ca3ca8.tar.gz archweb-f42f357fdf20d76bc5468ec227dac66cd0ca3ca8.zip |
Mirror tests (#78)release_2018-01-22
* mirrors: Move tests to mirrors/tests
Move the tests to separate files in mirrors/tests and expand the model
tests with tests for the Mirror class.
* Add CheckLocation test
* mirrors: Add tests for template filters
Include tests for the filters used in the mirrors views.
* devel: Add tests for template filter in_group
Include a test for a simple case of the in_group filter.
Diffstat (limited to 'mirrors/tests/test_templatetags.py')
-rw-r--r-- | mirrors/tests/test_templatetags.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/mirrors/tests/test_templatetags.py b/mirrors/tests/test_templatetags.py new file mode 100644 index 00000000..0ee2a34f --- /dev/null +++ b/mirrors/tests/test_templatetags.py @@ -0,0 +1,29 @@ +from datetime import timedelta + +from django.test import SimpleTestCase + +from mirrors.templatetags.mirror_status import duration, hours, floatvalue + + +class MirrorTemplateTagTest(SimpleTestCase): + def test_duration(self): + self.assertEqual(duration(None), u'') + + self.assertEqual(duration(timedelta(hours=5)), '5:00') + self.assertEqual(duration(timedelta(hours=5, seconds=61)), '5:01') + # Microseconds are skipped + self.assertEqual(duration(timedelta(microseconds=9999), ), '0:00') + + def test_hours(self): + self.assertEqual(hours(None), u'') + + self.assertEqual(hours(timedelta(hours=5)), '5 hours') + self.assertEqual(hours(timedelta(hours=1)), '1 hour') + self.assertEqual(hours(timedelta(seconds=60*60)), '1 hour') + + def test_floatvalue(self): + self.assertEqual(floatvalue(None), u'') + + self.assertEqual(floatvalue(123), '123.00') + self.assertEqual(floatvalue(123.1), '123.10') + self.assertEqual(floatvalue(123.1, 1), '123.1') |