diff --git a/src/python/tests/signature_tests.py b/src/python/tests/signature_tests.py index 5e68a4bd..8d29f992 100644 --- a/src/python/tests/signature_tests.py +++ b/src/python/tests/signature_tests.py @@ -6,6 +6,12 @@ demo_path = "../parser/test_demo.dem" +class WantedPropState: + def __init__(self, prop, state): + self.prop = prop + self.state = state + + class SignatureTest(TestCase): def test_parse_header_signature(self): parser = DemoParser(demo_path) @@ -60,6 +66,8 @@ def test_parse_event_signature(self): ) parser.parse_event("player_death", player=None, other=None) parser.parse_event("player_death", player=[], other=[]) + parser.parse_event("player_death", player_states=[WantedPropState("is_defusing", True)]) + parser.parse_event("player_death", other_states=[WantedPropState("is_bomb_planted", False)]) with self.assertRaises(TypeError): parser.parse_event("player_death", player=5, other=None) @@ -73,6 +81,12 @@ def test_parse_event_signature(self): with self.assertRaises(TypeError): parser.parse_event(5) + with self.assertRaises(AttributeError): + parser.parse_event("player_death", player_states=[{"prop": "is_defusing", "state": True}]) + + with self.assertRaises(AttributeError): + parser.parse_event("player_death", other_states=[{"prop": "is_bomb_planted", "state": True}]) + def test_parse_events_signature(self): parser = DemoParser(demo_path) @@ -95,6 +109,8 @@ def test_parse_events_signature(self): ) parser.parse_events(["player_death"], player=None, other=None) parser.parse_events(["player_death"], player=[], other=[]) + parser.parse_events(["player_death"], player_states=[WantedPropState("is_defusing", True)]) + parser.parse_events(["player_death"], other_states=[WantedPropState("is_bomb_planted", False)]) with self.assertRaises(TypeError): parser.parse_events(["player_death"], player=5, other=None) @@ -111,6 +127,12 @@ def test_parse_events_signature(self): with self.assertRaises(TypeError): parser.parse_events(5) + with self.assertRaises(AttributeError): + parser.parse_events(["player_death"], player_states=[{"prop": "is_defusing", "state": True}]) + + with self.assertRaises(AttributeError): + parser.parse_events(["player_death"], other_states=[{"prop": "is_bomb_planted", "state": True}]) + def test_parse_voice_signature(self): parser = DemoParser(demo_path) voice = parser.parse_voice() @@ -128,6 +150,7 @@ def test_parse_ticks_signature(self): parser.parse_ticks(["X", "Y"], players=[1, 2, 3], ticks=[1, 2, 3]) parser.parse_ticks(["X", "Y"], players=None, ticks=None) parser.parse_ticks(["X", "Y"], players=[], ticks=[]) + parser.parse_ticks(["X", "Y"], player_states=[WantedPropState("is_alive", True)], other_states=[WantedPropState("is_bomb_planted", True)]) with self.assertRaises(TypeError): parser.parse_ticks(["X", "Y"], players=5, ticks=None) @@ -141,6 +164,12 @@ def test_parse_ticks_signature(self): with self.assertRaises(TypeError): parser.parse_ticks(5) + with self.assertRaises(TypeError): + parser.parse_ticks(["X", "Y"], player_states=[1,2]) + + with self.assertRaises(AttributeError): + parser.parse_ticks(["X", "Y"], player_states=[{"prop": "is_alive", "state": True}]) + if __name__ == "__main__": unittest.main()