-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_main.py
82 lines (66 loc) · 1.57 KB
/
test_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import numpy as np
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def run_test(mmr0, rd0, winning_team, number_of_teams, mmr1, rd1):
response = client.post(
"/mmr/update",
json={
"ratings_list": mmr0,
"rds_list": rd0,
"winning_team": winning_team,
"number_of_teams": number_of_teams
},
)
assert response.status_code == 200
result = response.json()
ratings_list = result["ratings_list"]
rds_list = result["rds_list"]
rl = [np.round(num) for num in ratings_list]
rd = [np.round(num) for num in rds_list]
assert rl == mmr1
assert rd == rd1
def test_2x2():
run_test(
[1400, 1600, 1340, 1700],
[350, 350, 350, 350],
0,
2,
[1466, 1659, 1269, 1645],
[323, 327, 328, 337]
)
def test_1x1():
run_test(
[2000, 1500],
[90, 350],
0,
2,
[2002, 1467],
[89, 316]
)
run_test(
[2000, 1500],
[90, 350],
1,
2,
[1986, 1732],
[90, 336]
)
def test_4x4():
run_test(
[1400, 1600, 1340, 1700, 1563, 1490, 1520, 1590],
[350, 350, 350, 350, 278, 290, 310, 302],
0,
2,
[1455, 1649, 1398, 1746, 1531, 1453, 1479, 1553],
[327, 331, 326, 333, 275, 286, 306, 299]
)
def test_ffa():
run_test(
[1400, 1600, 1340, 1700],
[350, 350, 350, 350],
2,
4,
[1370, 1555, 1473, 1646],
[330, 329, 354, 330]
)