def test_delete_game(self, client, db, admin_headers): # test 404 game_url = url_for('api.game_by_id', game_id=1000000) rep = client.delete(game_url, headers=admin_headers) assert rep.status_code == HTTPStatus.NOT_FOUND game = GameFactory.build() db.session.add(game) db.session.commit() # test get game after deletion game_url = url_for('api.game_by_id', game_id=game.id) rep = client.delete(game_url, headers=admin_headers) assert rep.status_code == HTTPStatus.NO_CONTENT assert db.session.query(Game).filter_by(id=game.id).first() is None
def test_put_game(self, client, db, admin_headers): # test 404 game_url = url_for('api.game_by_id', game_id=1000000) rep = client.put(game_url, headers=admin_headers) assert rep.status_code == HTTPStatus.NOT_FOUND game = GameFactory.build() db.session.add(game) db.session.commit() new_data = {"date": str(datetime(2020, 12, 31))} # test updated game game_url = url_for('api.game_by_id', game_id=game.id) rep = client.put(game_url, json=new_data, headers=admin_headers) assert rep.status_code == HTTPStatus.OK data = rep.get_json()["game"] assert data["date"] == '2020-12-31T00:00:00' db.session.refresh(game)