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