From d847e758083e1d6c82986cbe53e7a28395008669 Mon Sep 17 00:00:00 2001 From: DivvyCr Date: Tue, 4 Aug 2020 17:45:30 +0100 Subject: [PATCH] Implement testing. NOTE: Have to change demo test, because game_stats.bumps is now more populated. --- carball/tests/stats/bump_test.py | 16 ++++++++++++++++ carball/tests/stats/demo_test.py | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 carball/tests/stats/bump_test.py diff --git a/carball/tests/stats/bump_test.py b/carball/tests/stats/bump_test.py new file mode 100644 index 00000000..40ba394a --- /dev/null +++ b/carball/tests/stats/bump_test.py @@ -0,0 +1,16 @@ +from carball.tests.utils import get_raw_replays, run_analysis_test_on_replay + +from carball.analysis.analysis_manager import AnalysisManager + + +class Test_Bumps: + def test_calculate_bumps_correctly(self, replay_cache): + def test(analysis: AnalysisManager): + proto_game = analysis.get_protobuf_data() + count_bumps = 0 + for i in proto_game.game_stats.bumps: + if not i.is_demo: + count_bumps += 1 + assert count_bumps == 3 + + run_analysis_test_on_replay(test, get_raw_replays()["3_BUMPS"], cache=replay_cache) diff --git a/carball/tests/stats/demo_test.py b/carball/tests/stats/demo_test.py index 1b013362..66f51f9a 100644 --- a/carball/tests/stats/demo_test.py +++ b/carball/tests/stats/demo_test.py @@ -7,7 +7,10 @@ class Test_Demos: def test_calculate_demos_correctly(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() - bumps = proto_game.game_stats.bumps - assert len(bumps) == 1 + count_demo_bumps = 0 + for i in proto_game.game_stats.bumps: + if i.is_demo: + count_demo_bumps += 1 + assert count_demo_bumps == 1 run_analysis_test_on_replay(test, get_raw_replays()["1_DEMO"], cache=replay_cache)