Exemple #1
0
    def test_game_info_non_existant(self):
        game = noa.game_info(nsuid="60010000000000")
        self.assertIsNone(game)

        game = noa.game_info(slug="unknown")
        self.assertIsNone(game)

        game = noa.game_info()
        self.assertIsNone(game)
    def test_noa(self):
        game: SwitchGame = noa.game_info(nsuid="70010000006442")

        self.assertEqual("Celeste", str(game))

        self.assertEqual("70010000006442", game.nsuid)
        self.assertEqual("ACF3", game.unique_id)

        self.assertEqual("Matt Makes Games Inc.", game.developer)
        self.assertEqual("Matt Makes Games Inc.", game.publisher)

        self.assertEqual("NA", game.region)
        self.assertEqual("Nintendo Switch", game.platform)

        self.assertEqual(2018, game.release_date.year)
        self.assertEqual(1, game.release_date.month)
        self.assertEqual(25, game.release_date.day)

        self.assertEqual(2, len(game.genres))
        self.assertEqual(10, len(game.languages))
        self.assertEqual(1, game.players)

        self.assertEqual("https://ec.nintendo.com/US/en/titles/70010000006442",
                         game.url(country="US"))

        self.assertEqual("https://ec.nintendo.com/CA/fr/titles/70010000006442",
                         game.url(country="CA", lang="fr"))

        self.assertFalse(game.demo)
        self.assertFalse(game.dlc)
        self.assertFalse(game.game_vouchers)
        self.assertFalse(game.nso_required)
        self.assertTrue(game.save_data_cloud)
    def test_noa(self):
        game: N3dsGame = noa.game_info(nsuid="50010000040656")

        self.assertEqual("Rhythm Heaven Megamix", str(game))

        self.assertEqual("50010000040656", game.nsuid)
        self.assertEqual("BPJ", game.unique_id)

        self.assertEqual("Nintendo", game.developer)
        self.assertEqual("Nintendo", game.publisher)

        self.assertEqual("NA", game.region)
        self.assertEqual("Nintendo 3DS", game.platform)

        self.assertEqual(2016, game.release_date.year)
        self.assertEqual(6, game.release_date.month)
        self.assertEqual(15, game.release_date.day)

        self.assertEqual(2, len(game.genres))
        self.assertEqual(4, game.players)

        self.assertEqual(
            "https://www.nintendo.com/en_US/games/detail/rhythm-heaven-megamix-3ds/",
            game.url(country="US"))

        self.assertEqual(
            "https://www.nintendo.com/fr_CA/games/detail/rhythm-heaven-megamix-3ds/",
            game.url(country="CA", lang="fr"))

        self.assertTrue(game.demo)
        self.assertFalse(game.dlc)
        self.assertTrue(game.street_pass)
        self.assertFalse(game.virtual_console)
Exemple #4
0
    def test_game_info_wiiu(self):
        game = noa.game_info(nsuid="20010000007686")

        self.assertEqual(game.platform, Platforms.NINTENDO_WIIU)
        self.assertEqual(game.region, Regions.NA)
        self.assertEqual(game.title, "Super Smash Bros.")
        self.assertEqual(game.nsuid, "20010000007686")
        # self.assertEqual(game.unique_id, "AXF")  TODO

        self.assertEqual(game.slug, "super-smash-bros-for-wii-u")

        self.assertEqual(game.players, 8)
        self.assertFalse(game.free_to_play)

        self.assertEqual(game.rating, (Ratings.ESRB, "Everyone 10+"))

        self.assertEqual(game.release_date.year, 2014)
        self.assertEqual(game.release_date.month, 11)
        self.assertEqual(game.release_date.day, 21)

        self.assertIn("Nintendo", game.publishers)

        self.assertEqual(game.features.get(Features.DEMO), False)

        self.assertEqual(
            game.eshop.us_en,
            "https://www.nintendo.com/en_US/games/detail/super-smash-bros-for-wii-u"
        )
Exemple #5
0
    def test_game_info_switch(self):
        game = noa.game_info(slug="super-smash-bros-ultimate-switch")

        self.assertEqual(game.platform, Platforms.NINTENDO_SWITCH)
        self.assertEqual(game.region, Regions.NA)
        self.assertEqual(game.title, "Super Smash Bros.™ Ultimate")
        self.assertEqual(game.nsuid, "70010000012332")
        # self.assertEqual(game.unique_id, "AAAB")  TODO

        self.assertEqual(game.slug, "super-smash-bros-ultimate-switch")

        self.assertEqual(game.players, 8)
        self.assertFalse(game.free_to_play)

        self.assertEqual(game.rating, (Ratings.ESRB, "Everyone 10+"))

        self.assertEqual(game.release_date.year, 2018)
        self.assertEqual(game.release_date.month, 12)
        self.assertEqual(game.release_date.day, 7)

        self.assertIn("Nintendo", game.publishers)

        self.assertEqual(game.features.get(Features.DEMO), False)
        self.assertEqual(game.features.get(Features.DLC), True)
        self.assertEqual(game.features.get(Features.NSO_REQUIRED), True)
        self.assertEqual(game.features.get(Features.SAVE_DATA_CLOUD), True)

        self.assertEqual(
            game.eshop.ca_fr,
            "https://www.nintendo.com/fr_CA/games/detail/super-smash-bros-ultimate-switch"
        )
Exemple #6
0
    def test_game_info_3ds(self):
        game = noa.game_info(nsuid="50010000023235")

        self.assertEqual(game.platform, Platforms.NINTENDO_3DS)
        self.assertEqual(game.region, Regions.NA)
        self.assertEqual(game.title, "Super Smash Bros.")
        self.assertEqual(game.nsuid, "50010000023235")
        # self.assertEqual(game.unique_id, "AXC")  TODO

        self.assertEqual(game.slug, "super-smash-bros-for-nintendo-3ds")

        self.assertEqual(game.players, 4)
        self.assertFalse(game.free_to_play)

        self.assertEqual(game.rating, (Ratings.ESRB, "Everyone 10+"))

        self.assertEqual(game.release_date.year, 2014)
        self.assertEqual(game.release_date.month, 10)
        self.assertEqual(game.release_date.day, 3)

        self.assertIn("Nintendo", game.publishers)

        self.assertEqual(game.features.get(Features.DEMO), True)

        self.assertEqual(
            game.eshop.ca_en,
            "https://www.nintendo.com/en_CA/games/detail/super-smash-bros-for-nintendo-3ds"
        )
Exemple #7
0
    def test_game_info_n3ds(self):
        game: N3dsGame = noa.game_info(nsuid="50010000023235")

        self.assertEqual("Super Smash Bros.", game.title)
        self.assertEqual("super-smash-bros-for-nintendo-3ds", game.slug)

        self.assertEqual("50010000023235", game.nsuid)
        self.assertEqual("AXC", game.unique_id)

        self.assertEqual("Sora Ltd.", game.developer)
        self.assertEqual("Nintendo", game.publisher)

        self.assertEqual("NA", game.region)
        self.assertEqual("Nintendo 3DS", game.platform)

        self.assertEqual(2014, game.release_date.year)
        self.assertEqual(10, game.release_date.month)
        self.assertEqual(3, game.release_date.day)

        self.assertIn(
            "Super Smash Bros. for Nintendo 3DS is the first portable entry",
            game.description,
        )

        self.assertEqual(["Action"], game.genres)
        self.assertEqual(4, game.players)
        self.assertEqual(1137, game.megabytes)

        self.assertIsNone(game.amiibo)
        self.assertEqual(True, game.demo)
        self.assertNotEqual(True, game.dlc)
        self.assertFalse(game.free_to_play)

        self.assertFalse(game.street_pass)
        self.assertFalse(game.virtual_console)
Exemple #8
0
    def test_game_info_switch(self):
        game: SwitchGame = noa.game_info(nsuid="70010000012332")

        self.assertEqual("Super Smash Bros.™ Ultimate", game.title)
        self.assertEqual("super-smash-bros-ultimate-switch", game.slug)

        self.assertEqual("70010000012332", game.nsuid)
        self.assertEqual("AAAB", game.unique_id)

        self.assertEqual("NA", game.region)
        self.assertEqual("Nintendo Switch", game.platform)

        self.assertEqual(2018, game.release_date.year)
        self.assertEqual(12, game.release_date.month)
        self.assertEqual(7, game.release_date.day)

        self.assertIn(
            "Gaming icons clash in the ultimate brawl you can play anytime, anywhere!",
            game.description)

        self.assertEqual(["Action", "Fighting", "Multiplayer"], game.genres)
        self.assertEqual([
            "Chinese",
            "Dutch",
            "English",
            "French",
            "German",
            "Italian",
            "Japanese",
            "Korean",
            "Russian",
            "Spanish",
        ], game.languages)
        self.assertEqual(8, game.players)
        self.assertEqual(13926, game.megabytes)

        self.assertIsNone(game.amiibo)
        self.assertFalse(game.demo)
        self.assertTrue(game.dlc)
        self.assertFalse(game.free_to_play)

        self.assertEqual(True, game.game_vouchers)
        self.assertIsNone(game.local_multiplayer)
        self.assertTrue(game.nso_required)
        self.assertTrue(game.save_data_cloud)
Exemple #9
0
    def test_get_prices_chunks(self):
        nsuid = "70010000000025"
        game = noa.game_info(nsuid=nsuid)

        games = [game] * 222

        with spy(prices, "_fetch_prices") as spied:
            found = list(prices.get_prices(games=games, country="US"))

        self.assertEqual(1, len(found))

        for nsuid, price in found:
            self.assertEqual(game.nsuid, nsuid)

            self.assertEqual("US", price.country)
            self.assertEqual("USD", price.currency)
            self.assertEqual(59.99, price.value)

        self.assertEqual(5, spied.call_count)
Exemple #10
0
    def test_prices(self):
        data = {
            "50010000000541": 19.99,  # Ocarina of Time (3DS/Select)
            "50010000006866":  5.99,  # Link's Awakening DX (3DS/VC)
            "50010000007271":  4.99,  # The Legend of Zelda (3DS/VC)
            "50010000007276":  4.99,  # The Adventure of Link (3DS/VC)
            "50010000014332":  5.99,  # Oracle of Ages (3DS/VC)
            "50010000014333":  5.99,  # Oracle of Seasons (3DS/VC)
            "50010000017216": 19.99,  # A Link Between Worlds (3DS/Select)
            "50010000027796": 19.99,  # Majora's Mask (3DS/Select)
            "50010000036995": 39.99,  # Tri Force Heroes (3DS)
            "50010000039719":  7.99,  # A Link to the Past (3DS/VC)
            "70010000000025": 59.99,  # Breath of the Wild (Switch)
            "70010000020033": 59.99,  # Link's Awakening (Switch)
        }

        games = [noa.game_info(nsuid=nsuid) for nsuid in data]

        with spy(prices, "_fetch_prices") as spied:
            for game in games:
                price = game.price(country="US")
                expected_price = data[game.nsuid]

                self.assertIn(price.nsuid, data)
                self.assertEqual("US", price.country)
                self.assertEqual("USD", price.currency)
                self.assertEqual(expected_price, price.value)

            self.assertEqual(len(games), spied.call_count)

        # Testing price fetching in bulk
        with spy(prices, "_fetch_prices") as spied:
            for nsuid, price in prices.get_prices(games=games, country="US"):
                self.assertIn(nsuid, data)
                self.assertIn(price.nsuid, data)

                expected_price = data[nsuid]

                self.assertEqual("US", price.country)
                self.assertEqual("USD", price.currency)
                self.assertEqual(expected_price, price.value)

            self.assertEqual(1, spied.call_count)
Exemple #11
0
    def test_sales(self, nsuid, on_sale):
        class MockedResponse:
            status_code = 200

            def json(self):
                return {
                    "personalized": False,
                    "country": "US",
                    "prices": [
                        {
                            "title_id": 70010000000025,
                            "sales_status": "onsale",
                            "regular_price": {
                                "amount": "$59.99",
                                "currency": "USD",
                                "raw_value": "59.99"
                            },
                        },
                        {
                            "title_id": 70010000000529,
                            "sales_status": "onsale",
                            "regular_price": {
                                "amount": "$59.99",
                                "currency": "USD",
                                "raw_value": "59.99"
                            },
                            "discount_price": {
                                "amount": "$41.99",
                                "currency": "USD",
                                "raw_value": "41.99",
                                "start_datetime": "2020-04-30T06:00:00Z",
                                "end_datetime": "2020-05-10T14:59:59Z"
                            }
                        }
                    ]
                }

            def raise_for_status(self):
                pass

        game = noa.game_info(nsuid=nsuid)

        with mock.patch("requests.get") as patched:
            patched.return_value = MockedResponse()
            price = game.price(country="US")

        self.assertEqual(game.nsuid, price.nsuid)
        self.assertFalse(price.is_free_to_play)

        self.assertEqual("US", price.country)
        self.assertEqual("USD", price.currency)
        self.assertEqual(59.99, price.value)

        if not on_sale:
            self.assertEqual("USD 59.99", str(price))
            self.assertEqual(None, price.sale_value)
            self.assertEqual(0, price.sale_discount)
            self.assertFalse(price.is_sale_active)
        else:
            self.assertEqual("USD 41.99*", str(price))
            self.assertEqual(41.99, price.sale_value)
            self.assertEqual(70, price.sale_discount)
            self.assertFalse(price.is_sale_active)
Exemple #12
0
 def test_noa(self, nsuid, title, checker):
     game = noa.game_info(nsuid)
     self.assertEqual(title, game.title)
     checker(self, game)