fix test that game cannot be started twice

This commit is contained in:
Thomas Rubini 2023-01-05 15:38:24 +01:00
parent 2f29aa48bc
commit 222a119a21
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
3 changed files with 4 additions and 2 deletions

View File

@ -205,6 +205,7 @@ def test_that_people_can_start_a_game():
def test_that_a_started_game_cannot_be_started_again(): def test_that_a_started_game_cannot_be_started_again():
owner = User("neosteopathie") owner = User("neosteopathie")
game_id = createGame(owner) game_id = createGame(owner)
startGame(owner)
with pytest.raises(TestException) as e: with pytest.raises(TestException) as e:
startGame(owner) startGame(owner)

View File

@ -50,7 +50,7 @@ class Game:
self.game_id = None self.game_id = None
self.owner = None self.owner = None
self.members = [] self.members = []
self.has_started = True self.has_started = False
def set_owner(self, username): def set_owner(self, username):
self.owner = Member(username) self.owner = Member(username)

View File

@ -59,10 +59,11 @@ def start_game():
if game == None: if game == None:
return {"error": 1, "msg": "this game doesn't exist"} return {"error": 1, "msg": "this game doesn't exist"}
print(game.has_started)
if game.has_started: if game.has_started:
return {"error": 1, "msg": "this game is already started"} return {"error": 1, "msg": "this game is already started"}
game.has_started = None game.has_started = True