-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
57 lines (50 loc) · 1.47 KB
/
test.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
from util import AsyncRequestPool, get
from server import Routes
import time
requestPool = AsyncRequestPool()
def with_game(response):
game_id = get("data.game_id", response)
requestPool.request(Routes.join_game, {"user_id": 5, "game_id": game_id}, print)
requestPool.request(
Routes.move, {"user_id": 2, "game_id": game_id, "column_id": 0}, print
)
requestPool.request(
Routes.move, {"user_id": 5, "game_id": game_id, "column_id": 0}, print
)
requestPool.request(
Routes.move, {"user_id": 2, "game_id": game_id, "column_id": 0}, print
)
requestPool.request(
Routes.check,
{
"game_id": game_id,
"board": [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0],
],
},
print,
)
requestPool.request(
Routes.check,
{
"game_id": game_id,
"board": [
[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, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0],
],
},
print,
)
requestPool.request(Routes.new_game, {"user_id": 2}, with_game)
while True:
requestPool.drain()
time.sleep(1)