Explorar el Código

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

Test _determine_margin() with margins specified as percentage
main
Rob Hallam hace 1 mes
padre
commit
5365d7d1e2
Se han modificado 1 ficheros con 17 adiciones y 0 borrados
  1. +17
    -0
      test/test_adjusters.py

+ 17
- 0
test/test_adjusters.py Ver fichero

@@ -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)

Cargando…
Cancelar
Guardar