Exemplo n.º 1
0
    def test_guild_from_content_in_war(self):
        content = self.load_resource(FILE_GUILD_IN_WAR)
        guild = Guild.from_content(content)

        self.assertIsInstance(guild, Guild)
        self.assertFalse(guild.open_applications)
        self.assertTrue(guild.active_war)
Exemplo n.º 2
0
    def test_guild_from_content(self):
        """Testing parsing a guild"""
        content = self.load_resource(FILE_GUILD_FULL)
        guild = Guild.from_content(content)
        self.assertIsInstance(guild, Guild, "Guild should be a Guild object.")
        self.assertEqual(guild.url, Guild.get_url(guild.name))
        self.assertEqual(guild.url_wars, Guild.get_url_wars(guild.name))
        self.assertTrue(guild.active, "Guild should be active")
        self.assertIsInstance(guild.founded, datetime.date, "Guild founded date should be an instance of datetime.date")
        self.assertTrue(guild.open_applications, "Guild applications should be open")
        self.assertIsNotNone(guild.description, "Guild should have a description")
        self.assertTrue(guild.members, "Guild should have members")
        self.assertEqual(guild.member_count, len(guild.members))
        self.assertTrue(guild.invites, "Guild should have invites")
        self.assertIsInstance(guild.online_members, list, "Guild online members should be a list.")
        self.assertEqual(len(guild.online_members), guild.online_count, "Length of online_members should be equal "
                                                                        "to online_count")
        self.assertTrue(guild.ranks, "Guild ranks should not be empty.")
        for member in guild.members:
            self.assertIsInstance(member.level, int, "Member level should be an integer.")
            self.assertIsInstance(member.joined, datetime.date, "Member's joined date should be datetime.date.")
        for invited in guild.invites:
            self.assertIsNotNone(invited.name, "Invited character's name should not be None.")
            self.assertIsInstance(invited.date, datetime.date, "Invited character's date should be datetime.date.")

        self.assertEqual(8, len(guild.members_by_rank['Vice Leader']))

        self.assertIsInstance(guild.guildhall, GuildHouse)
        self.assertEqual(guild.guildhall.owner, guild.members[0].name)
        self.assertEqual(guild.guildhall.world, guild.world)
        self.assertIsInstance(guild.guildhall.paid_until_date, datetime.date)
Exemplo n.º 3
0
    def test_guild_changes(self):
        content = self.load_resource(
            "website_changes/5_community_guilds_world_adra_ambassadors.txt")
        guild = Guild.from_content(content)

        self.assertEqual("Ambassadors", guild.name)
        self.assertTrue(guild.open_applications)
        self.assertEqual(31, len(guild.members))
        self.assertEqual("Adra", guild.world)
        self.assertIsNone(guild.guildhall)
        leader = guild.members[0]
        self.assertEqual("Emsky Ed", leader.name)
        self.assertEqual("Leader", leader.rank)
        self.assertEqual(293, leader.level)
        self.assertEqual(Vocation.ELDER_DRUID, leader.vocation)
        self.assertIsNone(leader.title)
Exemplo n.º 4
0
    async def fetch_guild(self, name):
        """Fetches a guild by its name from Tibia.com

        Parameters
        ----------
        name: :class:`str`
            The name of the guild. The case must match exactly.

        Returns
        -------
        :class:`Guild`
            The guild if found, else ``None``.

        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(Guild.get_url(name))
        guild = Guild.from_content(content)
        return guild
Exemplo n.º 5
0
 def test_guild_from_content_unrelated(self):
     """Testing parsing an unrelated tibiacom section"""
     content = self.load_resource(self.FILE_UNRELATED_SECTION)
     with self.assertRaises(InvalidContent):
         Guild.from_content(content)
Exemplo n.º 6
0
 def test_guild_from_content_not_found(self):
     """Testing parsing a non existent guild"""
     content = self.load_resource(FILE_GUILD_NOT_FOUND)
     guild = Guild.from_content(content)
     self.assertIsNone(guild)