def testPostV2NoEndTimestamp(self): log = GameLog(json=TEST_LOG_V2_NO_END_TIMESTAMP) game_key = log.put().urlsafe() request = Request.blank('/internal/add_game_to_statistic') request.method = 'POST' request.body = 'game_key=' + game_key response = request.get_response(main.app) self.assertEqual(response.status_int, 200)
def put(self, **kwargs): game_id = json.loads(self.request.body)['setup']['meta']['game.id'] game_key = ndb.Key(GameLog, game_id).get() if game_key is None: log = GameLog(json=self.request.body, id=game_id) game_key = log.put().urlsafe() taskqueue.add(url='/internal/add_game_to_statistic', params={'game_key': game_key}, countdown=5) self.response.set_status(201)
def testPostV1(self): game_id = json.loads(TEST_LOG_V1)['setup']['meta']['game.id'] log = GameLog(json=TEST_LOG_V1, id=game_id) game_key = log.put().urlsafe() request = Request.blank('/internal/add_game_to_statistic') request.method = 'POST' request.body = 'game_key=' + game_key response = request.get_response(main.app) self.assertEqual(response.status_int, 200)
def post(self, **kwargs): log = GameLog(json=self.request.body) taskqueue.add(url='/internal/add_game_to_statistic', params={'game_key': log.put().urlsafe()}, countdown=5) self.response.set_status(202)