Browse Source

test: [_determine_margin] add TTA._STRATEGY.PERCENT unit tests

Test _determine_margin() with margins specified as percentage
main
Rob Hallam 1 month ago
parent
commit
5365d7d1e2
1 changed files with 17 additions and 0 deletions
  1. +17
    -0
      test/test_adjusters.py

+ 17
- 0
test/test_adjusters.py View File

@@ -74,3 +74,20 @@ class TestTargetTimeAdjuster(unittest.TestCase):
# test
for time, margin, expected in test_cases:
self.assertEqual(tta._determine_margin(time, margin, strategy), expected)

with self.subTest("PERCENT"):
strategy = adjusters.TargetTimeAdjuster._STRATEGY.PERCENT
test_cases = []
# populate test cases with tuples of (time, margin, expected) as above
# zero margin
test_cases.append((60.0, 0.0, (60.0, 60.0)))
# margin of 5.0
test_cases.append((60.0, 5.0, (57.0, 63.0)))
# margin of 10.0
test_cases.append((60.0, 10.0, (54.0, 66.0)))
# margin of 100.0
test_cases.append((60.0, 100.0, (0.0, 120.0)))

# test
for time, margin, expected in test_cases:
self.assertEqual(tta._determine_margin(time, margin, strategy), expected)

Loading…
Cancel
Save