Exemple #1
0
    def test_remove_game_from_user_catalog(self) -> None:
        another_platform = create_platform()
        another_game = create_game(platforms=[self.platform, another_platform])
        another_user = create_user()
        CatalogManager.add_to_catalog(self.user, another_game.id,
                                      self.platform.id)
        CatalogManager.add_to_catalog(self.user, another_game.id,
                                      another_platform.id)
        CatalogManager.add_to_catalog(another_user, another_game.id,
                                      self.platform.id)

        CatalogManager.remove_from_catalog(self.user, another_game.id,
                                           self.platform.id)

        with self.assertRaises(UserGame.DoesNotExist) as error:
            UserGame.objects.get(user=self.user.id,
                                 game_id=another_game.id,
                                 platform_id=self.platform.id)
        self.assertTrue("does not exist" in str(error.exception))

        # but other associations still exist/not removed by accident
        UserGame.objects.get(user=self.user.id,
                             game_id=self.game.id,
                             platform_id=self.platform.id)
        UserGame.objects.get(user=self.user.id,
                             game_id=another_game.id,
                             platform_id=another_platform.id)
        # and similar association but for other users also still exists
        UserGame.objects.get(user=another_user.id,
                             game_id=another_game.id,
                             platform_id=self.platform.id)
Exemple #2
0
    def setUp(self):
        self.platform = create_platform()
        self.game = create_game(platforms=[self.platform])
        self.user = create_user()

        self.fetched_game = FetchedGame(publish_date=AN_IRRELEVANT_YEAR,
                                        name=self.game.name)
        self.fetched_game.fg_game = self.game
        self.fetched_game.save()
Exemple #3
0
    def setUp(self) -> None:
        self.platform = create_platform()
        self.game = create_game(platforms=[self.platform])
        self.user = create_user()

        user_game_data = {
            "user_id": self.user.id,
            "game_id": self.game.id,
            "platform_id": self.platform.id,
        }
        self.user_game = UserGame(**user_game_data)
        self.user_game.save()
Exemple #4
0
    def different_users_can_add_same_game_to_their_catalog(self) -> None:
        another_user = create_user()

        CatalogManager.add_to_catalog(another_user, self.game.id,
                                      self.platform.id)

        another_user_game = UserGame.objects.get(user=another_user.id,
                                                 game_id=self.game.id,
                                                 platform_id=self.platform.id)
        self.assertNotEqual(self.user_game.id, another_user_game.id)
        self.assertNotEqual(self.user_game.user.id, another_user_game.user.id)
        self.assertEqual(self.user_game.game.id, another_user_game.game.id)
        self.assertEqual(self.user_game.platform.id,
                         another_user_game.platform.id)
    def test_different_users_can_wishlist_same_title(self) -> None:
        another_user = create_user()

        wishlist_game_data = {
            "user_id": self.user.id,
            "game_id": self.game_1.id,
            "platform_id": self.platform_1.id,
        }

        wishlist_game = WishlistedUserGame(**wishlist_game_data)
        wishlist_game.save()

        wishlist_game_data["user_id"] = another_user.id
        wishlist_game = WishlistedUserGame(**wishlist_game_data)
        wishlist_game.save()
    def test_different_users_can_own_same_title(self) -> None:
        another_user = create_user()

        user_game_data = {
            "user_id": self.user.id,
            "game_id": self.game_1.id,
            "platform_id": self.platform_1.id,
        }

        user_game = UserGame(**user_game_data)
        user_game.save()

        user_game_data["user_id"] = another_user.id
        user_game = UserGame(**user_game_data)
        user_game.save()
 def setUp(self) -> None:
     self.platform_1 = create_platform()
     self.platform_2 = create_platform()
     self.game_1 = create_game(platforms=[self.platform_1, self.platform_2])
     self.user = create_user()