Skip to content

Commit

Permalink
test(templatetags): add test for conversion to knots
Browse files Browse the repository at this point in the history
  • Loading branch information
zyv committed Nov 4, 2023
1 parent 1beda39 commit f207d96
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from django.template import TemplateSyntaxError
from django.utils.safestring import SafeString

from logbook.models import SpeedUnit
from logbook.statistics.experience import ExperienceRecord, TotalsRecord
from logbook.templatetags.logbook_utils import replace, represent, subtract
from logbook.templatetags.logbook_utils import replace, represent, subtract, to_kt


class TestRepresent(TestCase):
Expand Down Expand Up @@ -40,3 +41,11 @@ def test_non_str_args(self):
self.assertRaises(TemplateSyntaxError, replace, "Hello, world!", 5, 7)
self.assertRaises(TemplateSyntaxError, replace, "Hello, world!", "foo", 7)
self.assertRaises(TemplateSyntaxError, replace, "Hello, world!", 5, "bar")


class TestToKT(TestCase):
def test_to_kt(self):
self.assertEqual(to_kt(100, SpeedUnit.KMH), 54)
self.assertEqual(to_kt(100, SpeedUnit.MPH), 87)
self.assertEqual(to_kt(100, SpeedUnit.KT), 100)
self.assertRaises(TemplateSyntaxError, to_kt, 100, "foo")

0 comments on commit f207d96

Please sign in to comment.