Пример #1
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)
Пример #2
0
    def test_sport_category(self):

        cat1 = models.SportCategory(name='Ball')

        cat2 = models.SportCategory(name='Basket Ball')
        cat2.add_parent(cat1)

        cat3 = models.SportCategory(name='Extreme Basket Ball')
        cat3.add_parent(cat2)

        msg = actions.sport_category_to_message(cat3)

        assert msg.name == 'Extreme Basket Ball'
        assert msg.paths[0] == 'ball/basket ball'
Пример #3
0
    def test_sport_profile_to_message(self):

        cat = models.SportCategory(name='Basketball')
        cat.put()

        profile = models.SportProfile(sport=cat.key, level=0)
        msg = actions.sports_profile_to_message(profile)

        assert msg.sport.name == "Basketball"
Пример #4
0
def create_sport_category(name):

    cat = models.SportCategory(name=name)
    cat.put()

    return cat


# Modify a game

# Get games made by a user
Пример #5
0
    def test(self):

        cat1 = models.SportCategory(name='Ball')
        cat1.put()

        cat2 = models.SportCategory(name='Archery')
        cat2.put()

        cat3 = models.SportCategory(name='Football')
        cat3.add_parent(cat1)
        cat3.put()

        everything = actions.get_all_categories()

        assert type(everything) == messages.CategoryList
        assert len(everything.categories) == 3

        assert everything.categories[0].name == 'Archery'
        assert everything.categories[2].name == 'Football'
        assert len(everything.categories[2].parent_ids) == 1
        assert everything.categories[2].parent_ids[0] == cat1.key.id()
Пример #6
0
    def setup(self):
        super(TestSportProfiles, self).setup()

        self.adrian = usermodels.User(full_name="Adrian", first_name="Adrian")
        self.adrian.initialise_new_token()
        self.adrian.put()

        self.tom = usermodels.User(full_name="Tom", first_name="Tom")
        self.tom.initialise_new_token()
        self.tom.put()

        self.cat = models.SportCategory(name='Basketball')
        self.cat.put()
Пример #7
0
    def setup(self):

        super(APITest, self).setup()

        # Expose the api
        self.api = modules.sports.api.Sports()

        # Put users in the database
        self.a_user = models.User(full_name="Dicky Johnson",
                                  first_name="Dicky")
        self.a_user.initialise_new_token()
        self.a_user.put()

        cat = models.SportCategory(name='American Football')
        cat.put()
Пример #8
0
    def test_delete_sport_profiles(self):

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

        cat = models.SportCategory(name='Football')
        cat.put()

        msg = messages.SportProfileRequest(sport_category_id=cat.key.id())

        actions.add_sport_profile(user, msg)
        actions.delete_sport_profile(user, msg)

        profiles = actions.get_user_sport_profiles(user).profiles

        assert len(profiles) == 0
Пример #9
0
    def test_get_sport_profiles(self):

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

        cat = models.SportCategory(name='Basketball')
        cat.put()

        msg = messages.SportProfileRequest(sport_category_id=cat.key.id())

        actions.add_sport_profile(user, msg)

        profiles = actions.get_user_sport_profiles(user).profiles

        assert profiles[0].sport.name == "Basketball"
        assert profiles[0].level == 0
Пример #10
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)
Пример #11
0
    def test(self):

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

        cat = models.SportCategory(name='Basketball')
        cat.put()

        msg = messages.SportProfileRequest(sport_category_id=cat.key.id())

        actions.add_sport_profile(user, msg)

        request = messages.SportmateSearchRequest()
        request.sport_category_id = 'basketball'

        result = actions.search_for_sportmates(request).profiles

        assert result[0].sport.name == "Basketball"
        assert result[0].user.full_name == "Adrian"
Пример #12
0
    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)
Пример #13
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)