25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_producers.py 2.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. """test_producers.py -- test the producers in the pipeline (eg ffmpeg, visualisation, json)"""
  2. import unittest
  3. import pipeline.video_producers as producers
  4. class MockFeature():
  5. """Mock feature object for testing JSONProducer"""
  6. def __init__(self, interval):
  7. self.interval = interval
  8. def to_json(self):
  9. return {"interval": self.interval}
  10. class TestFfmpegVideoProducer(unittest.TestCase):
  11. """Test FfmpegVideoProducer (produces videos using ffmpeg)"""
  12. def test_init_empty(self):
  13. # test with no features -- should raise ValueError
  14. with self.assertRaises(ValueError):
  15. producers.FfmpegVideoProducer(features=None)
  16. def test_init(self):
  17. # test with features
  18. feature = MockFeature(interval="")
  19. features = [feature]
  20. vidprod = producers.FfmpegVideoProducer(features=features)
  21. self.assertEqual(vidprod.features, features)
  22. def test_ffmpeg_feature_to_clip(self):
  23. # TODO
  24. pass
  25. def test_ffmpeg_concat_clips(self):
  26. # TODO
  27. pass
  28. def test_produce(self):
  29. """Test we can call produce without error"""
  30. # TODO
  31. pass
  32. class TestVisualisationProducer(unittest.TestCase):
  33. """Test VisualisationProducer (produces matplotlib visualisations)"""
  34. def test_init_empty(self):
  35. # test with no features -- should raise ValueError
  36. with self.assertRaises(ValueError):
  37. producers.VisualisationProducer(features=None)
  38. def test_init(self):
  39. # test with features
  40. feature = MockFeature(interval="")
  41. features = [feature]
  42. visprod = producers.VisualisationProducer(features=features)
  43. self.assertEqual(visprod.features, features)
  44. def test_produce(self):
  45. """Test we can call produce without error"""
  46. # TODO
  47. pass
  48. class TestJSONProducer(unittest.TestCase):
  49. def test_init_empty(self):
  50. # test with no features -- should raise ValueError
  51. with self.assertRaises(ValueError):
  52. producers.JSONProducer(features=None)
  53. def test_init(self):
  54. # test with features
  55. feature = MockFeature(interval="")
  56. features = [feature]
  57. jsonprod = producers.JSONProducer(features=features)
  58. self.assertEqual(jsonprod.features, features)
  59. def test_produce(self):
  60. """Test we can call produce without error"""
  61. feature = MockFeature(interval="")
  62. features = [feature]
  63. jsonprod = producers.JSONProducer(features=features)
  64. jsonprod.produce()