def test_checkStream_noContainer(self): # test whether nothing happens if container is none mockframe = testlib.mockFrame() # monkey patch onupdate lib.onUpdate = lambda x: 1 lib.createStatusWidget(mockframe) lib.checkStream(mockframe) self.assertEqual(mockframe.status.get(), "yellow") self.assertEqual(mockframe.streamActive, False)
def test_checkStream_containerRunningEarly(self): """Tests whether the reaction to a running container that has no valid bitrate output is correct.""" # test whether nothing happens if container is none mockframe = testlib.mockFrame() mockframe.container = testlib.mockContainer(status="running", log=b"asdf") # monkey patch onupdate lib.onUpdate = lambda x: 1 lib.createStatusWidget(mockframe) lib.checkStream(mockframe) self.assertEqual(mockframe.status.get(), "green") self.assertEqual(mockframe.streamActive, False) self.assertEqual(mockframe.lbl_StreamSpeed["text"], "-/-")
def test_checkStream_containerCreated_finished(self): """Check whether reaction to a container that has been created and finished succesfully is correct.""" mockframe = testlib.mockFrame() mockframe.container = testlib.mockContainer(status="created", log=b"asdf") # monkey patch onupdate oldOnUpdate = lib.onUpdate lib.onUpdate = lambda x: 1 # monkeypatch client oldClient = lib.docker.from_env lib.docker.from_env = lambda: testlib.mockEngine(testlib.mockImages()) lib.createStatusWidget(mockframe) lib.checkStream(mockframe) self.assertEqual(mockframe.status.get(), "yellow") self.assertEqual(mockframe.streamActive, False) self.assertEqual(mockframe.lbl_StreamSpeed["text"], "Inactive") self.assertEqual(mockframe.container, None) # undo monkeypatch lib.onUpdate = oldOnUpdate lib.docker.from_env = oldClient
def test_checkStream_containerCreated_inList(self): """Tests whether the reaction to a created container that is then the client.containers.list is correct""" mockframe = testlib.mockFrame() mockframe.container = testlib.mockContainer(status="created", log=b"asdf") # monkey patch onupdate oldOnUpdate = lib.onUpdate lib.onUpdate = lambda x: 1 # monkeypatch client oldClient = lib.docker.from_env lib.docker.from_env = lambda: testlib.mockEngine( testlib.mockImages(), containers=[mockframe.container]) lib.createStatusWidget(mockframe) lib.checkStream(mockframe) self.assertEqual(mockframe.status.get(), "green") self.assertEqual(mockframe.streamActive, False) self.assertEqual(mockframe.lbl_StreamSpeed["text"], "-/-") # undo monkeypatch lib.onUpdate = oldOnUpdate lib.docker.from_env = oldClient