37 lines
905 B
Python
37 lines
905 B
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from fastapi.testclient import TestClient
|
|
|
|
from shortdeck_server.main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
def pretty(o):
|
|
print(json.dumps(o, ensure_ascii=False, indent=2))
|
|
|
|
|
|
def run():
|
|
print('POST /join aa')
|
|
r = client.post('/join', json={'name':'aa'})
|
|
pretty(r.json())
|
|
|
|
print('POST /join bb')
|
|
r = client.post('/join', json={'name':'bb'})
|
|
pretty(r.json())
|
|
|
|
print('GET /get_game_state?player_id=0')
|
|
r = client.get('/get_game_state', params={'player_id':0})
|
|
pretty(r.json())
|
|
|
|
print('POST /apply_action check by pid=0')
|
|
r = client.post('/apply_action', json={'player_id':0, 'action':'check'})
|
|
pretty(r.json())
|
|
|
|
print('POST /apply_action bet 10 by pid=1')
|
|
r = client.post('/apply_action', json={'player_id':1, 'action':'bet', 'amount':10})
|
|
pretty(r.json())
|
|
|
|
if __name__ == '__main__':
|
|
run()
|