From 445efac7f3bbe107e4736c70f6ddcaabf19760c4 Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Thu, 22 Aug 2024 15:09:28 +0100 Subject: [PATCH] test: [producers] add test_produce() functionality Uses unittest.mock.path to patch out call to matplotlib.pyplot.savefig() TODO: better, more-granular tests of the bits of functionality here --- test/test_producers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/test_producers.py b/test/test_producers.py index 7d5f057..5f7d4ce 100644 --- a/test/test_producers.py +++ b/test/test_producers.py @@ -70,8 +70,16 @@ class TestVisualisationProducer(unittest.TestCase): def test_produce(self): """Test we can call produce without error""" - # TODO - pass + # to do this, we need to mock out plt.savefig(path) + feature = mocks.MockFeature(interval=mocks.MockInterval(start=0, end=5), + source=mocks.MockSource(path="test.mp4")) + features = [feature] + visprod = producers.VisualisationProducer(features=features) + with unittest.mock.patch("matplotlib.pyplot.savefig") as mock_savefig: + visprod.produce() + mock_savefig.assert_called() + + # TODO: more more granular test coverage of produce behaviour class TestJSONProducer(unittest.TestCase): def test_init_empty(self):