You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
1.6 KiB

#!/usr/bin/env python3
"""Test endpoints for gogame
"""
import json
import requests
import provoj
import time
import os
os.system("mongo gogame --eval 'db.dropDatabase()'")
URL = "http://127.0.0.1:5000"
t = provoj.NewTest("gogame")
registerData = {
"name": "user00",
"password": "user00password",
"email": "user00@email.com",
}
r = requests.post(URL + "/register", json=registerData)
t.rStatus("post /register", r)
jsonR = r.json()
print(jsonR)
loginData = {
"email": "user00@email.com",
"password": "user00password",
}
r = requests.post(URL + "/login", json=loginData)
t.rStatus("post /login", r)
jsonR = r.json()
print(jsonR)
userid = jsonR["user"]["id"]
r = requests.get(URL + "/resources/"+ userid)
t.rStatus("get /resources", r)
jsonR = r.json()
print(jsonR)
time.sleep(1)
r = requests.get(URL + "/resources/"+ userid)
t.rStatus("get /resources", r)
jsonR = r.json()
print(jsonR)
r = requests.get(URL + "/resources/"+ userid)
t.rStatus("get /resources", r)
jsonR = r.json()
print(jsonR)
r = requests.get(URL + "/planets/"+userid)
t.rStatus("post /planets/:userid", r)
jsonR = r.json()
print(jsonR)
print(jsonR["planets"][0])
planetid = jsonR["planets"][0]["id"]
d = {
"planetid": planetid,
"building": "metalplant",
}
r = requests.post(URL + "/buildings/"+userid, json=d)
t.rStatus("post /building/:userid", r)
jsonR = r.json()
print(jsonR)
d = {
"planetid": planetid,
"building": "ressearchlab",
}
r = requests.post(URL + "/buildings/"+userid, json=d)
t.rStatus("post /building/:userid", r)
jsonR = r.json()
print(jsonR)
t.printScores()