Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

test_producers.py 1.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 TestVisualisationProducer(unittest.TestCase):
  11. """Test VisualisationProducer (produces matplotlib visualisations)"""
  12. def test_init_empty(self):
  13. # test with no features -- should raise ValueError
  14. with self.assertRaises(ValueError):
  15. producers.VisualisationProducer(features=None)
  16. def test_init(self):
  17. # test with features
  18. feature = MockFeature(interval="")
  19. features = [feature]
  20. visprod = producers.VisualisationProducer(features=features)
  21. self.assertEqual(visprod.features, features)
  22. def test_produce(self):
  23. """Test we can call produce without error"""
  24. # TODO
  25. pass
  26. class TestJSONProducer(unittest.TestCase):
  27. def test_init_empty(self):
  28. # test with no features -- should raise ValueError
  29. with self.assertRaises(ValueError):
  30. producers.JSONProducer(features=None)
  31. def test_init(self):
  32. # test with features
  33. feature = MockFeature(interval="")
  34. features = [feature]
  35. jsonprod = producers.JSONProducer(features=features)
  36. self.assertEqual(jsonprod.features, features)
  37. def test_produce(self):
  38. """Test we can call produce without error"""
  39. feature = MockFeature(interval="")
  40. features = [feature]
  41. jsonprod = producers.JSONProducer(features=features)
  42. jsonprod.produce()