diff --git a/src/backend/backend_ga.py b/src/backend/backend_ga.py index 7171c09..9bbec94 100644 --- a/src/backend/backend_ga.py +++ b/src/backend/backend_ga.py @@ -115,6 +115,9 @@ def generate_new_cid_file(self): def cid_file_initialized(self): return self.cid is not None + def set_stats(self, data: dict): + pass + def is_valid_cid(cid: str): try: diff --git a/src/main_test.py b/src/main_test.py index 29d79de..f599f87 100644 --- a/src/main_test.py +++ b/src/main_test.py @@ -72,7 +72,8 @@ def make_message(self, client_id, app_name, app_version, category, action, label 'event_count': value, 'session_id': session_id, 'app_name': app_name, - 'app_version': app_version} + 'app_version': app_version, + 'usage_count': 1} } ]} diff --git a/src/utils/stats_processor_test.py b/src/utils/stats_processor_test.py index e321d0e..5b8aaf3 100644 --- a/src/utils/stats_processor_test.py +++ b/src/utils/stats_processor_test.py @@ -30,36 +30,36 @@ def test_stats_usage(self): # Test first creation of statistics file self.stats_processor.update_stats(test_data1) - assert os.path.exists(stats_filename) + self.assertTrue(os.path.exists(stats_filename)) with open(stats_filename, 'r') as file: - assert file.readlines() == ['{\n', ' "value1": 12,\n', ' "value2": 7,\n', ' "value3": 8\n', '}'] + self.assertTrue(file.readlines() == ['{\n', ' "value1": 12,\n', ' "value2": 7,\n', ' "value3": 8\n', '}']) status, res = self.stats_processor.get_stats() - assert status - assert res == test_data1 + self.assertTrue(status) + self.assertTrue(res == test_data1) # Test updating of statistics file test_data2 = {"value1": 15, "a": "abs"} self.stats_processor.update_stats(test_data2) - assert os.path.exists(stats_filename) + self.assertTrue(os.path.exists(stats_filename)) with open(stats_filename, 'r') as file: - assert file.readlines() == ['{\n', ' "value1": 15,\n', ' "a": "abs"\n', '}'] + self.assertTrue(file.readlines() == ['{\n', ' "value1": 15,\n', ' "a": "abs"\n', '}']) status, res = self.stats_processor.get_stats() - assert status - assert res == test_data2 + self.assertTrue(status) + self.assertTrue(res == test_data2) # Test removing of statistics file self.stats_processor.remove_stats_file() - assert not os.path.exists(stats_filename) + self.assertFalse(os.path.exists(stats_filename)) status, res = self.stats_processor.get_stats() - assert not status - assert res == {} + self.assertFalse(status) + self.assertTrue(res == {}) # Test attempt to read incorrect statistics file with open(stats_filename, 'w') as file: file.write("{ abc") status, res = self.stats_processor.get_stats() - assert not status - assert res == {} + self.assertFalse(status) + self.assertTrue(res == {})