From 8a5a84b6be879ce6d2166811439d576fbfcf3db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=9Aliwa?= <58854456+sliwaszymon@users.noreply.github.com> Date: Thu, 28 Mar 2024 08:31:54 +0100 Subject: [PATCH] more details in statistical tests for status subcounting --- backend/test_transactions.csv | 2 +- backend/tests/test_statistics.py | 51 +++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/backend/test_transactions.csv b/backend/test_transactions.csv index 3fc1a024..7419c11d 100644 --- a/backend/test_transactions.csv +++ b/backend/test_transactions.csv @@ -4,7 +4,7 @@ Azure;gpt-35-turbo;50;50;200;2023-11-01T12:01:00.000Z;2023-11-01T12:01:11.000Z Azure;gpt-35-turbo;15;59;200;2023-11-01T12:01:50.000Z;2023-11-01T12:01:51.000Z Azure;gpt-35-turbo;69;0;401;2023-11-01T12:03:23.000Z;2023-11-01T12:03:25.000Z Azure;gpt-35-turbo;80;0;303;2023-11-01T12:04:45.000Z;2023-11-01T12:04:45.000Z -Azure;gpt-35-turbo;200;356;200;2023-11-01T12:04:59.000Z;2023-11-01T12:04:59.000Z +Azure;gpt-35-turbo;200;356;200;2023-11-01T12:04:58.000Z;2023-11-01T12:04:58.999Z OpenAI;gpt-3.5-turbo;65;77;200;2023-11-01T12:06:01.000Z;2023-11-01T12:06:11.000Z OpenAI;gpt-4-0613;300;32;200;2023-11-01T12:06:23.000Z;2023-11-01T12:06:25.000Z Google Cloud;gemini-pro;42;65;200;2023-11-01T12:15:41.000Z;2023-11-01T12:15:41.000Z diff --git a/backend/tests/test_statistics.py b/backend/tests/test_statistics.py index ad8628b4..f6ee8d71 100644 --- a/backend/tests/test_statistics.py +++ b/backend/tests/test_statistics.py @@ -17,6 +17,8 @@ def test_transaction_count_min_5min(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(3, 1, 2, 0)] def test_transaction_count_min_30min(client, application): @@ -35,6 +37,8 @@ def test_transaction_count_min_30min(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 6 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) for stat in + response.json()] == [(3, 1, 2, 0), (2, 0, 0, 0), (0, 0, 0, 0), (1, 0, 1, 0), (2, 1, 0, 0), (3, 0, 0, 2)] def test_transaction_count_min_1h(client, application): @@ -53,6 +57,9 @@ def test_transaction_count_min_1h(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 12 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) for stat in + response.json()] == [(3, 1, 2, 0), (2, 0, 0, 0), (0, 0, 0, 0), (1, 0, 1, 0), (2, 1, 0, 0), (3, 0, 0, 2), + (0, 0, 0, 0), (1, 0, 0, 0), (2, 0, 0, 0), (0, 0, 0, 0), (5, 0, 2, 0), (4, 1, 2, 0)] def test_transaction_count_min_empty(client, application): @@ -89,6 +96,8 @@ def test_transaction_count_hour_30min(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) for stat in + response.json()] == [(11, 2, 3, 2)] def test_transaction_count_hour_1h(client, application): @@ -107,6 +116,8 @@ def test_transaction_count_hour_1h(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 2 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) for stat in + response.json()] == [(23, 3, 7, 2), (0, 0, 0, 0)] def test_transaction_count_hour_24h(client, application): @@ -125,7 +136,12 @@ def test_transaction_count_hour_24h(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 24 - + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) for stat in + response.json()] == [(23, 3, 7, 2), (1, 0, 0, 0), (1, 0, 2, 0), (1, 1, 0, 0), (0, 0, 0, 0), (1, 0, 0, 0), + (0, 0, 0, 0), (0, 0, 0, 0), (2, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), + (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (2, 0, 0, 2), (0, 0, 0, 0), + (0, 0, 0, 0), (0, 0, 0, 0), (4, 0, 0, 0), (0, 0, 0, 0), (1, 0, 0, 0), (1, 0, 0, 0)] + def test_transaction_count_hour_empty(client, application): # arrange @@ -161,6 +177,8 @@ def test_transaction_count_day_6h(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(27, 4, 9, 2)] def test_transaction_count_day_1d(client, application): @@ -179,6 +197,8 @@ def test_transaction_count_day_1d(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(29, 4, 9, 2)] def test_transaction_count_day_24h(client, application): @@ -197,6 +217,8 @@ def test_transaction_count_day_24h(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 2 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(6, 1, 2, 0), (9, 0, 0, 2)] def test_transaction_count_day_7d(client, application): @@ -215,6 +237,9 @@ def test_transaction_count_day_7d(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 7 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(29, 4, 9, 2), (10, 0, 0, 2), (0, 0, 0, 0), (0, 0, 0, 0), + (0, 0, 0, 0), (1, 1, 1, 0), (0, 0, 0, 0)] def test_transaction_count_day_1mo(client, application): @@ -233,6 +258,13 @@ def test_transaction_count_day_1mo(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 30 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(29, 4, 9, 2), (10, 0, 0, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), + (1, 1, 1, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), + (0, 0, 0, 0), (3, 0, 0, 0), (1, 0, 0, 0), (0, 0, 2, 0), (0, 0, 0, 0), + (0, 0, 0, 0), (1, 0, 0, 0), (0, 0, 0, 0), (1, 0, 0, 0), (1, 0, 0, 0), + (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (1, 0, 0, 1), + (0, 0, 0, 0), (0, 0, 0, 0), (1, 0, 0, 0), (0, 0, 0, 0), (1, 0, 0, 0)] def test_transaction_count_week_3d(client, application): @@ -251,6 +283,8 @@ def test_transaction_count_week_3d(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(39, 4, 9, 4)] def test_transaction_count_week_7d(client, application): @@ -269,6 +303,8 @@ def test_transaction_count_week_7d(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 2 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(40, 5, 10, 4), (0, 0, 0, 0)] def test_transaction_count_week_2mo(client, application): @@ -287,6 +323,8 @@ def test_transaction_count_week_2mo(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 9 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(40, 5, 10, 4), (4, 0, 0, 0), (3, 0, 2, 0), (1, 0, 0, 1), (5, 1, 0, 0), (3, 0, 0, 0), (2, 0, 0, 0), (0, 3, 0, 0), (0, 0, 0, 0)] def test_transaction_count_week_empty(client, application): @@ -323,6 +361,8 @@ def test_transaction_count_month_7d(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(40, 5, 10, 4)] def test_transaction_count_month_1mo(client, application): @@ -341,6 +381,8 @@ def test_transaction_count_month_1mo(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(50, 5, 12, 5)] def test_transaction_count_month_6mo(client, application): @@ -359,6 +401,9 @@ def test_transaction_count_month_6mo(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 6 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(0, 0, 0, 0), (50, 5, 12, 5), (10, 4, 0, 0), + (6, 1, 1, 1), (0, 0, 0, 0), (7, 4, 4, 1)] def test_transaction_count_month_empty(client, application): @@ -395,6 +440,8 @@ def test_transaction_count_year_2mo(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 1 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(59, 9, 12, 5)] def test_transaction_count_year_2y(client, application): @@ -413,6 +460,8 @@ def test_transaction_count_year_2y(client, application): # assert assert response.status_code == 200 assert len(response.json()) == 2 + assert [(stat['status_200'], stat['status_300'], stat['status_400'], stat['status_500']) + for stat in response.json()] == [(60, 9, 12, 5), (13, 5, 5, 2)] def test_transaction_count_year_empty(client, application):