def test(self): tom = usermodels.User(full_name="Tom", first_name="Tom") tom.put() user = usermodels.User(full_name="Adrian", first_name="Adrian") user.put() msg = messages.NewGame(categories=["Basket Ball"], level=1, time=datetime.now(), name="Adrian's big play off", players_needed=2, lat=34.0, lon=89.0) game = actions.create_new_game(user, msg) actions.join_game(tom, game) game_list = models.UserGameList.get_or_create_addable_game_list(tom) game = game.key.get() assert game_list.games[0] == game.key assert game.players[0] == user.key assert game.players[1] == tom.key assert game.players_joined == 2 assert not game.show_in_search
def setup(self): super(TestListGames, self).setup() # Put some data into the database cat = models.SportCategory(name='Ball games') cat.put() cat1 = models.SportCategory(name='Basket Ball') cat1.add_parent(cat) cat1.put() cat2 = models.SportCategory(name='Football') cat2.add_parent(cat) cat2.put() user = usermodels.User(full_name="Adrian Letchford", first_name="Adrian") user.put() tom = usermodels.User(full_name="Tom", first_name="Tom") tom.put() msg = messages.NewGame(categories=["Basket Ball"], level=1, time=datetime.now() + timedelta(days=5), name="Adrian's big play off", players_needed=2, lat=34.0, lon=89.0) game = actions.create_new_game(user, msg) actions.join_game(tom, game)
def join_game(self, request): """The authenticating user joins a game.""" auth_user = verify_and_get_user(token=request.token) game = actions.join_game(auth_user, ndb.Key(urlsafe=request.key)) return actions.game_model_to_message(game)
def test_join_full_game(self): tom = usermodels.User(full_name="Tom", first_name="Tom") tom.put() user = usermodels.User(full_name="Adrian", first_name="Adrian") user.put() msg = messages.NewGame(categories=["Basket Ball"], level=1, time=datetime.now(), name="Adrian's big play off", players_needed=1, lat=34.0, lon=89.0) game = actions.create_new_game(user, msg) actions.join_game(tom, game)
def setup(self): super(TestLeaveGame, self).setup() self.tom = usermodels.User(full_name="Tom", first_name="Tom") self.tom.put() self.user = usermodels.User(full_name="Adrian", first_name="Adrian") self.user.put() msg = messages.NewGame(categories=["Basket Ball"], level=1, time=datetime.now(), name="Adrian's big play off", players_needed=2, lat=34.0, lon=89.0) self.game = actions.create_new_game(self.user, msg) actions.join_game(self.tom, self.game)
def setup(self): super(TestLeaveGame, self).setup() self.tom = usermodels.User(full_name="Tom", first_name="Tom") self.tom.initialise_new_token() self.tom.put() self.user = usermodels.User(full_name="Adrian", first_name="Adrian") self.user.put() cat = models.SportCategory(name='Basketball') cat.put() msg = messages.NewGame(categories=["Basketball"], time=datetime.now(), players_needed=2, lat=34.0, lon=89.0) self.game = actions.create_new_game(self.user, msg) actions.join_game(self.tom, self.game)
def setup(self): super(TestGetUpcoming, self).setup() self.tom = usermodels.User(full_name="Tom", first_name="Tom") self.tom.put() self.user = usermodels.User(full_name="Adrian", first_name="Adrian") self.user.put() self.cat = models.SportCategory(name='Basketball') self.cat.put() msg = messages.NewGame(categories=["Basketball"], level=1, time=datetime.now() + timedelta(days=7), name="Adrian's big play off", players_needed=2, lat=34.0, lon=89.0) self.game = actions.create_new_game(self.user, msg) actions.join_game(self.tom, self.game)