コード例 #1
0
ファイル: tests_guild.py プロジェクト: EnzzoCaaue/tibia.py
 def test_listed_guild_from_content(self):
     """Testing parsing the list of guilds of a world"""
     content = self.load_resource(FILE_GUILD_LIST)
     guilds = ListedGuild.list_from_content(content)
     self.assertTrue(guilds)
     self.assertIsNotNone(ListedGuild.get_world_list_url(guilds[0].world))
     self.assertEqual("Zuna", guilds[0].world)
     self.assertTrue(guilds[0].active)
     self.assertFalse(guilds[-1].active)
コード例 #2
0
 def test_listed_guild_from_tibiadata(self):
     """Testing parsing a guild list from TibiaData"""
     content = self._load_resource(FILE_GUILD_TIBIADATA_LIST)
     guilds = ListedGuild.list_from_tibiadata(content)
     self.assertTrue(guilds)
     self.assertIsNotNone(
         ListedGuild.get_world_list_url_tibiadata(guilds[0].world))
     self.assertEqual("Zunera", guilds[0].world)
     self.assertIsInstance(guilds[0], ListedGuild)
     self.assertTrue(guilds[0].active)
     self.assertFalse(guilds[-1].active)
コード例 #3
0
ファイル: tests_client.py プロジェクト: ZenelShabani/tibia.py
    async def test_client_fetch_world_guilds(self, mock):
        """Testing fetching a world's guild list"""
        world = "Zuna"
        content = self.load_resource(FILE_GUILD_LIST)
        mock.get(ListedGuild.get_world_list_url(world),
                 status=200,
                 body=content)
        guilds = await self.client.fetch_world_guilds(world)

        self.assertIsInstance(guilds.data[0], ListedGuild)
コード例 #4
0
ファイル: client.py プロジェクト: jpars26/BotDiscord
    async def fetch_world_guilds(self, world: str):
        """Fetches the list of guilds in a world from Tibia.com

        Parameters
        ----------
        world: :class:`str`
            The name of the world.

        Returns
        -------
        list of :class:`ListedGuild`
            The lists of guilds in the world.

        Raises
        ------
        Forbidden
            If a 403 Forbidden error was returned.
            This usually means that Tibia.com is rate-limiting the client because of too many requests.
        NetworkError
            If there's any connection errors during the request.
        """
        content = await self._get(ListedGuild.get_world_list_url(world))
        guilds = ListedGuild.list_from_content(content)
        return guilds
コード例 #5
0
ファイル: tests_guild.py プロジェクト: EnzzoCaaue/tibia.py
 def test_listed_guild_from_content_unrelated(self):
     """Testing parsing and unrelated section"""
     content = self.load_resource(self.FILE_UNRELATED_SECTION)
     with self.assertRaises(InvalidContent):
         ListedGuild.list_from_content(content)
コード例 #6
0
ファイル: tests_guild.py プロジェクト: EnzzoCaaue/tibia.py
 def test_listed_guild_from_content_not_found(self):
     """Testing parsing the guild list of a world that doesn't exist"""
     content = self.load_resource(FILE_GUILD_LIST_NOT_FOUND)
     guilds = ListedGuild.list_from_content(content)
     self.assertIsNone(guilds)
コード例 #7
0
 def test_listed_guild_from_tibiadata_invalid_json(self):
     """Testing parsing an invalid json"""
     with self.assertRaises(InvalidContent):
         ListedGuild.list_from_tibiadata("<b>Not JSON</b>")
コード例 #8
0
 def test_listed_guild_from_tibiadata_unrelated_section(self):
     """Testing parsing an unrelated section"""
     content = self._load_resource(
         tests.tests_character.FILE_CHARACTER_TIBIADATA)
     with self.assertRaises(InvalidContent):
         ListedGuild.list_from_tibiadata(content)
コード例 #9
0
 def test_listed_guild_from_tibiadata_not_found(self):
     """Testing parsing a non existent guild"""
     content = self._load_resource(FILE_GUILD_TIBIADATA_LIST_NOT_FOUND)
     guilds = ListedGuild.list_from_tibiadata(content)
     # There's no way to tell if the searched world doesn't exist or has no guilds
     self.assertEqual(guilds, [])