def test_delete(self): players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": players})}, auth=self.auth) print r.text game_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) assert(r.status_code == 200) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(data["games"]) == 1) r = requests.delete(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) r = requests.get(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) assert(r.status_code == 404) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(data["games"]) == 0) id, auth = get_new_user_id_auth() players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": players})}, auth=self.auth) game_id = r.json["data"]["id"] r = requests.delete(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=auth) assert(r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) assert(r.status_code == 200) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(data["games"]) == 1)
def test_delete(self): r = requests.delete(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, 23498), auth=self.auth) assert(r.status_code == 404) r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) pl_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(r["players"]) == 1) r = requests.delete(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 404) r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(r["players"]) == 0) # Test delete with wrong user id, auth = get_new_user_id_auth() r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) pl_id = r.json["data"]["id"] r = requests.delete(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=auth) assert(r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(r["players"]) == 1)
def test_create(self): # No name field r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) assert (r.status_code == 200) assert ("id" in r.json["data"]) pl_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(r["players"]) == 1) assert (r["players"][0]["name"] == "foo") r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 200) assert (r.json["data"]["player"]["name"] == "foo") # Test post from wrong user id, auth = get_new_user_id_auth() r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "bar"}, auth=auth) assert (r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 200) assert (r.json["data"]["player"]["name"] == "foo")
def test_mod(self): r = requests.post(BASE + "/users/%s/contests" % self.id, data={ "data": json.dumps({ "name": "boo", "type": "manyranked" }) }, auth=self.auth).json contest_id = r["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth).json["data"] assert (r["contest"]["name"] == "boo") r = requests.put(BASE + "/users/%s/contests/%s" % (self.id, contest_id), data={"name": "bar"}, auth=self.auth) r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth).json["data"] assert (r["contest"]["name"] == "bar") # Test put from wrong user id, auth = get_new_user_id_auth() r = requests.put(BASE + "/users/%s/contests/%s" % (self.id, contest_id), data={"name": "baz"}, auth=auth) assert (r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth).json["data"] # no change assert (r["contest"]["name"] == "bar")
def test_delete(self): players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "2012-6-12", "ranking": players }) }, auth=self.auth) print r.text game_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) assert (r.status_code == 200) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(data["games"]) == 1) r = requests.delete(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) r = requests.get(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) assert (r.status_code == 404) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(data["games"]) == 0) id, auth = get_new_user_id_auth() players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "2012-6-12", "ranking": players }) }, auth=self.auth) game_id = r.json["data"]["id"] r = requests.delete(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=auth) assert (r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/games/%s" % (self.id, self.contest_id, game_id), auth=self.auth) assert (r.status_code == 200) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(data["games"]) == 1)
def test_delete(self): r = requests.delete(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, 23498), auth=self.auth) assert (r.status_code == 404) r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) pl_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(r["players"]) == 1) r = requests.delete(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 404) r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(r["players"]) == 0) # Test delete with wrong user id, auth = get_new_user_id_auth() r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) pl_id = r.json["data"]["id"] r = requests.delete(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=auth) assert (r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(r["players"]) == 1)
def test_mod(self): r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"name": "boo", "type": "manyranked"})}, auth=self.auth).json contest_id = r["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth).json["data"] assert(r["contest"]["name"] == "boo") r = requests.put(BASE + "/users/%s/contests/%s" % (self.id, contest_id), data={"name": "bar"}, auth=self.auth) r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth).json["data"] assert(r["contest"]["name"] == "bar") # Test put from wrong user id, auth = get_new_user_id_auth() r = requests.put(BASE + "/users/%s/contests/%s" % (self.id, contest_id), data={"name": "baz"}, auth=auth) assert(r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth).json["data"] # no change assert(r["contest"]["name"] == "bar")
def test_delete(self): r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"name": "boo", "type": "manyranked"})}, auth=self.auth).json contest_id = r["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth) assert(r.status_code == 200) r = requests.delete(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth) assert(r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth) assert(r.status_code == 404) r = requests.delete(BASE + "/users/%s/contests/%s" % (self.id, 239482), auth=self.auth) assert(r.status_code == 404) # Test delete from wrong user id, auth = get_new_user_id_auth() r = requests.post(BASE + "/users/%s/contests" % id, data={"data": json.dumps({"name": "boo", "type": "manyranked"})}, auth=auth) assert(r.status_code == 200) r = requests.post(BASE + "/users/%s/contests" % id, data={"data": json.dumps({"name": "boo", "type": "manyranked"})}, auth=self.auth) assert(r.status_code == 403)
def test_create(self): r = requests.post(BASE + "/users/%s/contests" % self.id) assert(r.status_code == 401) r = requests.post(BASE + "/users/%s/contests" % self.id, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"name": "boo"})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"type": "manyranked"})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"name": "boo", "type": "notreal"})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"name": "boo", "type": "manyranked"})}, auth=self.auth) assert(r.status_code == 200) # Test create from wrong user id, auth = get_new_user_id_auth() r = requests.post(BASE + "/users/%s/contests" % id, data={"data": json.dumps({"name": "boo", "type": "manyranked"})}, auth=self.auth) assert(r.status_code == 403)
def test_delete(self): r = requests.post(BASE + "/users/%s/contests" % self.id, data={ "data": json.dumps({ "name": "boo", "type": "manyranked" }) }, auth=self.auth).json contest_id = r["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth) assert (r.status_code == 200) r = requests.delete(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth) assert (r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s" % (self.id, contest_id), auth=self.auth) assert (r.status_code == 404) r = requests.delete(BASE + "/users/%s/contests/%s" % (self.id, 239482), auth=self.auth) assert (r.status_code == 404) # Test delete from wrong user id, auth = get_new_user_id_auth() r = requests.post( BASE + "/users/%s/contests" % id, data={"data": json.dumps({ "name": "boo", "type": "manyranked" })}, auth=auth) assert (r.status_code == 200) r = requests.post( BASE + "/users/%s/contests" % id, data={"data": json.dumps({ "name": "boo", "type": "manyranked" })}, auth=self.auth) assert (r.status_code == 403)
def test_create(self): r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12"})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": "Sdf"})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": 123})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": []})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-16-12", "ranking": json.dumps([1, 2])})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "bullshit", "ranking": json.dumps([1, 2])})}, auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": json.dumps([1, 2])})}, auth=self.auth) assert(r.status_code == 400) # Now create players players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": players})}, auth=self.auth) assert(r.status_code == 200) assert("id" in r.json["data"]) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(data["games"]) == 1) # Test with an incorrect session id, auth = get_new_user_id_auth() players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12", "ranking": json.dumps(players)})}, auth=auth) assert(r.status_code == 403) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(data["games"]) == 1)
def test_modify(self): r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, 23948), data={"name": "bar"}, auth=self.auth) assert(r.status_code == 404) r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) pl_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.json["data"]["player"]["name"] == "foo") r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 400) r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), data={"name": "bar"}, auth=self.auth) assert(r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.json["data"]["player"]["name"] == "bar") # Test delete with wrong user id, auth = get_new_user_id_auth() r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), data={"name": "baz"}, auth=auth) assert(r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.json["data"]["player"]["name"] == "bar")
def test_create(self): # No name field r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth) assert(r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) assert(r.status_code == 200) assert("id" in r.json["data"]) pl_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), auth=self.auth).json["data"] assert(len(r["players"]) == 1) assert(r["players"][0]["name"] == "foo") r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 200) assert(r.json["data"]["player"]["name"] == "foo") # Test post from wrong user id, auth = get_new_user_id_auth() r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "bar"}, auth=auth) assert(r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert(r.status_code == 200) assert(r.json["data"]["player"]["name"] == "foo")
def test_create(self): r = requests.post(BASE + "/users/%s/contests" % self.id) assert (r.status_code == 401) r = requests.post(BASE + "/users/%s/contests" % self.id, auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"name": "boo"})}, auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({"type": "manyranked"})}, auth=self.auth) assert (r.status_code == 400) r = requests.post( BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({ "name": "boo", "type": "notreal" })}, auth=self.auth) assert (r.status_code == 400) r = requests.post( BASE + "/users/%s/contests" % self.id, data={"data": json.dumps({ "name": "boo", "type": "manyranked" })}, auth=self.auth) assert (r.status_code == 200) # Test create from wrong user id, auth = get_new_user_id_auth() r = requests.post( BASE + "/users/%s/contests" % id, data={"data": json.dumps({ "name": "boo", "type": "manyranked" })}, auth=self.auth) assert (r.status_code == 403)
def test_modify(self): r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, 23948), data={"name": "bar"}, auth=self.auth) assert (r.status_code == 404) r = requests.post(BASE + "/users/%s/contests/%s/players" % (self.id, self.contest_id), data={"name": "foo"}, auth=self.auth) pl_id = r.json["data"]["id"] r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.json["data"]["player"]["name"] == "foo") r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.status_code == 400) r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), data={"name": "bar"}, auth=self.auth) assert (r.status_code == 200) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.json["data"]["player"]["name"] == "bar") # Test delete with wrong user id, auth = get_new_user_id_auth() r = requests.put(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), data={"name": "baz"}, auth=auth) assert (r.status_code == 403) r = requests.get(BASE + "/users/%s/contests/%s/players/%s" % (self.id, self.contest_id, pl_id), auth=self.auth) assert (r.json["data"]["player"]["name"] == "bar")
def test_create(self): r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({"date": "2012-6-12"})}, auth=self.auth) assert (r.status_code == 400) r = requests.post( BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({ "date": "2012-6-12", "ranking": "Sdf" })}, auth=self.auth) assert (r.status_code == 400) r = requests.post( BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({ "date": "2012-6-12", "ranking": 123 })}, auth=self.auth) assert (r.status_code == 400) r = requests.post( BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={"data": json.dumps({ "date": "2012-6-12", "ranking": [] })}, auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "2012-16-12", "ranking": json.dumps([1, 2]) }) }, auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "bullshit", "ranking": json.dumps([1, 2]) }) }, auth=self.auth) assert (r.status_code == 400) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "2012-6-12", "ranking": json.dumps([1, 2]) }) }, auth=self.auth) assert (r.status_code == 400) # Now create players players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "2012-6-12", "ranking": players }) }, auth=self.auth) assert (r.status_code == 200) assert ("id" in r.json["data"]) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(data["games"]) == 1) # Test with an incorrect session id, auth = get_new_user_id_auth() players = self.add_players(self.contest_id) r = requests.post(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), data={ "data": json.dumps({ "date": "2012-6-12", "ranking": json.dumps(players) }) }, auth=auth) assert (r.status_code == 403) data = requests.get(BASE + "/users/%s/contests/%s/games" % (self.id, self.contest_id), auth=self.auth).json["data"] assert (len(data["games"]) == 1)