def testDeleteTournament_hands_removed(self):
self.loginUser()
id = self.AddBasicTournament()
id2 = self.AddBasicTournament()
params = {'calls': {}, 'ns_score': 25, 'ew_score': 75}
self.testapp.put_json("/api/tournaments/{}/hands/1/2/3".format(id), params)
params = {'calls': {"south" : "T"}, 'ns_score': 225, 'ew_score': -25}
self.testapp.put_json("/api/tournaments/{}/hands/1/2/3".format(id2), params)
self.assertEqual(2, len(ndb.Query(kind = "HandScore").fetch()))
response = self.testapp.delete("/api/tournaments/{}".format(id))
self.assertEqual(response.status_int, 204)
response = self.testapp.get("/api/tournaments/{}".format(id),
expect_errors=True)
self.assertEqual(response.status_int, 404)
self.assertEqual(1, len(ndb.Query(kind = "HandScore").fetch()))
response = self.testapp.get("/api/tournaments")
tourneys = json.loads(response.body)
self.assertIsNotNone(tourneys["tournaments"])
self.assertEqual(1, len(tourneys["tournaments"]))
self.assertEqual(id2, tourneys["tournaments"][0]["id"])
response = self.testapp.get("/api/tournaments/{}".format(id2),
expect_errors=True)
response_dict = json.loads(response.body)
self.CheckBasicTournamentMetadataUnchanged(response_dict)
self.assertEqual({"south" : "T"}, response_dict["hands"][0]['calls'])
self.assertEqual(225, response_dict["hands"][0]['ns_score'])
self.assertEqual(-25, response_dict["hands"][0]['ew_score'])
self.assertEqual(1, response_dict["hands"][0]['board_no'])
self.assertEqual(2, response_dict["hands"][0]['ns_pair'])
self.assertEqual(3, response_dict["hands"][0]['ew_pair'])
tournament_handler_test.py 文件源码
python
阅读 15
收藏 0
点赞 0
评论 0
评论列表
文章目录