From b1e58ec559338a65462a1db16ce8d1690ef0398c Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 7 Apr 2021 00:09:23 +0100 Subject: [PATCH] Add play on load test (currently fails) --- tests/test_player.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/test_player.py b/tests/test_player.py index a87c882..9187d05 100644 --- a/tests/test_player.py +++ b/tests/test_player.py @@ -168,6 +168,41 @@ class TestPlayer(unittest.TestCase): self.assertFalse(json_obj["playing"]) + # This test checks if the player progresses to the next item and plays on load. + def test_play_on_load(self): + self._send_msg_wait_OKAY("ADD:"+ getPlanItemJSON(2,0)) + + self._send_msg_wait_OKAY("ADD:"+ getPlanItemJSON(2,1)) + + self._send_msg_wait_OKAY("PLAYONLOAD:True") + self._send_msg_wait_OKAY("REPEAT:none") + + self._send_msg_wait_OKAY("LOAD:0") + + # We should be playing the first item. + response = self._send_msg_wait_OKAY("STATUS") + self.assertTrue(response) + json_obj = json.loads(response) + self.assertTrue(json_obj["playing"]) + self.assertEqual(json_obj["loaded_item"]["weight"], 0) + + + self._send_msg_wait_OKAY("PLAY") + + time.sleep(2) + + # Now we should be onto playing the second item. + response = self._send_msg_wait_OKAY("STATUS") + self.assertTrue(response) + json_obj = json.loads(response) + self.assertTrue(json_obj["playing"]) + self.assertEqual(json_obj["loaded_item"]["weight"], 1) + + + + + + @@ -177,7 +212,7 @@ class TestPlayer(unittest.TestCase): if __name__ == '__main__': try: unittest.main() - except Exception as e: + except SystemExit as e: print("Tests failed :/", e) else: print("Tests passed!")