|
@@ -1,5 +1,6 @@ |
|
|
"""test_adjusters.py -- test pipeline Adjusters (eg TargetTimeAdjuster)""" |
|
|
"""test_adjusters.py -- test pipeline Adjusters (eg TargetTimeAdjuster)""" |
|
|
import unittest |
|
|
import unittest |
|
|
|
|
|
import unittest.mock as mock |
|
|
import pipeline.adjusters as adjusters |
|
|
import pipeline.adjusters as adjusters |
|
|
|
|
|
|
|
|
class TestAdjuster(unittest.TestCase): |
|
|
class TestAdjuster(unittest.TestCase): |
|
@@ -15,3 +16,28 @@ class TestAdjuster(unittest.TestCase): |
|
|
adjuster = adjusters.Adjuster() |
|
|
adjuster = adjusters.Adjuster() |
|
|
self.assertEqual(adjuster.adjust(), []) |
|
|
self.assertEqual(adjuster.adjust(), []) |
|
|
self.assertEqual(adjuster.features, []) |
|
|
self.assertEqual(adjuster.features, []) |
|
|
|
|
|
|
|
|
|
|
|
class TestTargetTimeAdjuster(unittest.TestCase): |
|
|
|
|
|
"""Test the TargetTimeAdjuster |
|
|
|
|
|
|
|
|
|
|
|
TTA drops Features until the target time is reached (or within a margin)""" |
|
|
|
|
|
|
|
|
|
|
|
def test_init(self): |
|
|
|
|
|
"""Test the TTA can be initialised""" |
|
|
|
|
|
tta = adjusters.TargetTimeAdjuster() |
|
|
|
|
|
self.assertEqual(tta.features, []) |
|
|
|
|
|
|
|
|
|
|
|
def test_features_total_time(self): |
|
|
|
|
|
"""Test the TTA can calculate the total time of Features |
|
|
|
|
|
|
|
|
|
|
|
Test: |
|
|
|
|
|
- input duration floats: 1.0, 2.0, 3.0, 4.0 == 10.0 |
|
|
|
|
|
""" |
|
|
|
|
|
tta = adjusters.TargetTimeAdjuster() |
|
|
|
|
|
features = [] |
|
|
|
|
|
for i in range(1, 5): |
|
|
|
|
|
features.append(mock.Mock(duration=i*1.0)) |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(tta._features_total_time(features), 10.0) |
|
|
|
|
|
self.assertEqual(tta._features_total_time([]), 0.0) |
|
|
|
|
|
self.assertIs(type(tta._features_total_time([])), float) |