Beispiel #1
0
 def test_parseFailure(self):
     badContainer1 = testlib.mockContainer(b"I am a failure!")
     self.assertTrue(lib.parseFailure(badContainer1))
     badContainer2 = testlib.mockContainer(b"Everything is an error..")
     self.assertTrue(lib.parseFailure(badContainer2))
     badContainer3 = testlib.mockContainer(b"Not found...")
     self.assertTrue(lib.parseFailure(badContainer3))
Beispiel #2
0
 def setUp(self) -> None:
     self.GoodContainer = testlib.mockContainer(
         b"\rframe 918.3kbits/s 38.8image 25 fps \frame 920.3kbits/s"
         b"\rframe 918.3kbits/s 38.8image 25 fps \frame 920.3kbits/s"
         b"\rframe 918.3kbits/s 38.8image 25 fps \frame 920.3kbits/s"
         b"\rframe 918.3kbits/s 38.8image 25 fps \frame 920.3kbits/s")
     self.badContainer = testlib.mockContainer(b"press [q] press [h]")
     self.goodConfig = pd.DataFrame({
         "File": [
             "test_files\\vids\\test.mp4",
             "test_files\\vids\\test2.mp4",
             "test_files\\vids\\test4.mp4",
         ],
         "Date/Time": [
             pd.Timestamp("2025-06-21 12:00:00"),
             pd.Timestamp("2025-06-22 13:00:00"),
             pd.Timestamp("2025-07-23 14:00:00"),
         ],
     })
     self.goodCredentials = {
         "User": 12345,
         "Password": 678910,
         "rtmp-URL": "rtmp://i.amagood.server",
         "playpath": "dclive_0_1@2345",
     }
     self.mockframe = testlib.mockFrame()
     # draw grid onto mockFrame
     lib.drawConfigGrid(self.mockframe)
     # monkey patch lib.showerror so that I can catch to result
     lib.showerror = testlib.raiseAssertion
Beispiel #3
0
 def test_countImages(self):
     rightContainer = testlib.mockContainer(name="asdf")
     # 0 images
     oldClient = lib.docker.from_env
     lib.docker.from_env = lambda: testlib.mockEngine(containers=[])
     self.assertEqual(lib.countImages("asdf"), 0)
     # 2 images
     lib.docker.from_env = lambda: testlib.mockEngine(
         containers=[rightContainer, rightContainer])
     self.assertEqual(lib.countImages("asdf"), 2)
     # restore old client
     lib.docker.from_env = oldClient
Beispiel #4
0
 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"], "-/-")
Beispiel #5
0
 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
Beispiel #6
0
 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