Example #1
0
    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
Example #2
0
    def test_create_new_game(self):

        user = usermodels.User(full_name="Adrian", first_name="Adrian")
        user.put()

        msg = messages.NewGame(categories=["American Football"],
                               level=1,
                               time=datetime.now(),
                               name="Adrian's big play off",
                               players_needed=2,
                               location_name="Some place",
                               lat=34.0,
                               lon=89.0,
                               description="Please bring shoes.")

        game = actions.create_new_game(user, msg)

        game = game.key.get()

        assert game.key.parent() == user.key
        assert game.players_needed == 2
        assert game.category[0].id() == "american football"
        assert game.geo.lat == 34
        assert game.geo.lon == 89
        assert game.location_name == "Some place"
        assert game.creator == user.key
        assert len(game.players) == 1
        assert game.players[0] == user.key
        assert game.description == "Please bring shoes."
Example #3
0
    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)
Example #4
0
    def setup(self):
        super(TestLeaveGameEmpty, self).setup()

        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)
Example #5
0
    def setup(self):
        super(TestGameComments, self).setup()

        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=2),
                               name="Adrian's big play off",
                               players_needed=2,
                               lat=34.0,
                               lon=89.0)

        self.game = actions.create_new_game(self.user, msg)
Example #6
0
    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 test_create_new_game(self):

        send_msg = messages.NewGame(token=self.a_user.get_token(),
                                    categories=["American Football"],
                                    level=1,
                                    time=datetime.now(),
                                    end_time=datetime.now() +
                                    timedelta(days=1),
                                    name="Adrian's big play off",
                                    players_needed=2,
                                    lat=34.0,
                                    lon=89.0,
                                    description="please bring shoes.")

        game = self.api.create_new_game(send_msg)

        assert game.players_needed == 2
        assert game.lat == 34
        assert game.description == "please bring shoes."
Example #8
0
    def test_create_new_game_minimum(self):

        user = usermodels.User(full_name="Adrian", first_name="Adrian")
        user.put()

        msg = messages.NewGame(categories=["American Football"],
                               time=datetime.now(),
                               players_needed=2,
                               location_name="Some place")

        game = actions.create_new_game(user, msg)

        game = game.key.get()

        assert game.key.parent() == user.key
        assert game.players_needed == 2
        assert game.category[0].id() == "american football"
        assert game.location_name == "Some place"
        assert game.creator == user.key
        assert len(game.players) == 1
        assert game.players[0] == user.key
    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)
Example #10
0
    def setup(self):
        super(TestGetUpcoming, 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()

        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)