Skip to content

Commit

Permalink
more details in statistical tests for status subcounting
Browse files Browse the repository at this point in the history
  • Loading branch information
sliwaszymon committed Mar 28, 2024
1 parent 1cc110f commit 8a5a84b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/test_transactions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 50 additions & 1 deletion backend/tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 8a5a84b

Please sign in to comment.