|
|
@@ -91,3 +91,31 @@ class TestTargetTimeAdjuster(unittest.TestCase): |
|
|
|
# test |
|
|
|
for time, margin, expected in test_cases: |
|
|
|
self.assertEqual(tta._determine_margin(time, margin, strategy), expected) |
|
|
|
|
|
|
|
def test_adjust_no_change(self): |
|
|
|
"""Test adjusting of list of Features using TTA -- no change to list of Features |
|
|
|
|
|
|
|
Cases: |
|
|
|
- no Features --> [] |
|
|
|
- [Features] with total time < target time --> unchanged list |
|
|
|
- [Features] with total time = target time --> unchanged list |
|
|
|
|
|
|
|
TODO: test with Features > target |
|
|
|
""" |
|
|
|
with self.subTest("no Features"): |
|
|
|
tta = adjusters.TargetTimeAdjuster() |
|
|
|
self.assertEqual(tta.adjust(), []) |
|
|
|
|
|
|
|
with self.subTest("Features < target time"): |
|
|
|
features = [] |
|
|
|
for i in range(1, 5): |
|
|
|
features.append(make_feature(duration=i*1.0)) |
|
|
|
tta = adjusters.TargetTimeAdjuster(features=features, target_time=20.0) |
|
|
|
self.assertEqual(tta.adjust(), features) |
|
|
|
|
|
|
|
with self.subTest("Features = target time"): |
|
|
|
features = [] |
|
|
|
for i in range(1, 5): |
|
|
|
features.append(make_feature(duration=i*1.0)) |
|
|
|
tta = adjusters.TargetTimeAdjuster(features=features, target_time=10.0) |
|
|
|
self.assertEqual(tta.adjust(), features) |