From 0a9e3d4539231cecbfaf1d4617a8224ac2673ae7 Mon Sep 17 00:00:00 2001 From: Burathar Date: Sat, 18 Jul 2020 20:22:39 +0200 Subject: [PATCH] add method to the_hunt.py to create testing objects in database --- the_hunt.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/the_hunt.py b/the_hunt.py index fb91633..fa47d34 100755 --- a/the_hunt.py +++ b/the_hunt.py @@ -9,4 +9,29 @@ def make_shell_context(): return {'db': db, 'Game' : Game, 'Player' : Player, 'Objective' : Objective, 'Location' : Location, 'Notification' : Notification, 'GamePlayer' : GamePlayer, 'PlayerFoundObjective' : PlayerFoundObjective, 'NotificationPlayer' : NotificationPlayer, - 'PlayerCaughtPlayer' : PlayerCaughtPlayer, 'Role' : Role, 'GameState' : GameState} \ No newline at end of file + 'PlayerCaughtPlayer' : PlayerCaughtPlayer, 'Role' : Role, 'GameState' : GameState, + 'create_objects' : create_objects} + +def create_objects(): + g1 = Game(name='TestGame') + g2 = Game(name='MyGame') + + p1 = Player(name='Marijn') + p2 = Player(name='Rogier') + p3 = Player(name='Henk') + p4 = Player(name='Emma') + p5 = Player(name='Demi') + + g1.game_players.append(GamePlayer(player=p1, role=Role.owner)) + g1.game_players.append(GamePlayer(player=p2, role=Role.hunter)) + g1.game_players.append(GamePlayer(player=p3, role=Role.hunter)) + g1.game_players.append(GamePlayer(player=p4, role=Role.bunny)) + g1.game_players.append(GamePlayer(player=p5, role=Role.bunny)) + + g2.game_players.append(GamePlayer(player=p1, role=Role.bunny)) + g2.game_players.append(GamePlayer(player=p2, role=Role.owner)) + g2.game_players.append(GamePlayer(player=p3, role=Role.hunter)) + + db.session.add(g1) + db.session.add(g2) + db.session.commit() \ No newline at end of file