瀏覽代碼

test: add 'missing' tests

Identified when checking coverage while only testing utils
main
Rob Hallam 2 月之前
父節點
當前提交
3173babcff
共有 1 個文件被更改,包括 20 次插入5 次删除
  1. +20
    -5
      test/test_utils.py

+ 20
- 5
test/test_utils.py 查看文件

@@ -208,11 +208,18 @@ class TestInterval(unittest.TestCase):

def test_move_end(self):
"""Test the move_end method - changes end time to time specified, keeps start time constant"""
interval = utils.Interval(start=self.start, end=self.end)
interval.move_end(15)
self.assertEqual(interval.start, 0)
self.assertEqual(interval.end, 15)
self.assertEqual(interval.duration, 15)
with self.subTest("non-relative"):
interval = utils.Interval(start=self.start, end=self.end)
interval.move_end(15)
self.assertEqual(interval.start, 0)
self.assertEqual(interval.end, 15)
self.assertEqual(interval.duration, 15)
with self.subTest("relative"):
interval = utils.Interval(start=self.start, end=self.end)
interval.move_end(5, relative=True)
self.assertEqual(interval.start, 0)
self.assertEqual(interval.end, 15)
self.assertEqual(interval.duration, 15)

def test_update_duration(self):
"""Test the update_duration method - changes duration to time specified, keeps start time constant"""
@@ -354,6 +361,14 @@ class TestFeature(unittest.TestCase):
self.assertEqual(feature1, feature2)
self.assertNotEqual(feature1, feature3)

def test_feature_no_score(self):
"""Test creating a Feature without a score"""
source = MockSource("source")
interval = MockInterval(0, 10)
feature_extractor = "test"
feature = utils.Feature(interval, source, feature_extractor)
self.assertEqual(feature.score, 0.0)

# unhappy path tests

def test_init_unhappy(self):


Loading…
取消
儲存