def test_character_from_tibiadata_position(self): """Testing parsing a character with position""" content = self._load_resource( FILE_CHARACTER_TIBIADATA_SPECIAL_POSITION) char = Character.from_tibiadata(content) self.assertEqual(char.name, "Steve") self.assertEqual(char.position, "CipSoft Member") self.assertEqual(char.account_information.position, "CipSoft Member")
def test_character_from_tibiadata_summon_deaths(self): """Testing parsing a character with summon deaths""" content = self._load_resource(FILE_CHARACTER_TIBIADATA_DEATHS_SUMMON) char = Character.from_tibiadata(content) self.assertTrue(char.deaths) summon_death = char.deaths[2] self.assertTrue(summon_death.killers[2].summon, "a fire elemental") self.assertTrue(summon_death.killers[2].name, "Hasi Pupsi")
def test_character_from_tibiadata_deleted(self): """Testing parsing a deleted character""" content = self._load_resource(FILE_CHARACTER_TIBIADATA_DELETED) char = Character.from_tibiadata(content) self.assertEqual(char.url_tibiadata, Character.get_url_tibiadata(char.name)) self.assertIsInstance(char, Character) self.assertTrue(char.deleted) self.assertIsInstance(char.deletion_date, datetime.datetime) self.assertIsNone(char.guild_name) self.assertIsNone(char.last_login)
def test_character_from_tibiadata_unhidden(self): """Testing parsing an unhidden character""" content = self._load_resource(FILE_CHARACTER_TIBIADATA_UNHIDDEN) char = Character.from_tibiadata(content) self.assertIsNotNone(char.account_information) self.assertTrue(char.other_characters) self.assertFalse(char.hidden) self.assertIsInstance(char.house, CharacterHouse) self.assertEqual(char.house.owner, char.name) self.assertEqual(char.house.town, "Kazordoon") self.assertEqual(char.house.world, char.world) self.assertIsInstance(char.house.paid_until_date, datetime.date)
def test_character_from_tibiadata(self): """Testing parsing TibiaData content""" content = self._load_resource(FILE_CHARACTER_TIBIADATA) char = Character.from_tibiadata(content) self.assertEqual(char.url_tibiadata, Character.get_url_tibiadata(char.name)) self.assertIsInstance(char, Character) self.assertIsNotNone(char.guild_name) self.assertIsInstance(char.last_login, datetime.datetime) self.assertIsInstance(char.house, CharacterHouse) self.assertEqual(char.house.owner, char.name) self.assertEqual(char.house.town, "Ankrahmun") self.assertEqual(char.house.world, char.world) self.assertIsInstance(char.house.paid_until_date, datetime.date) self.assertTrue(char.deaths[3].by_player)
def test_character_from_tibiadata_unrelated_json(self): """Testing parsing an unrelated TibiaData section""" with self.assertRaises(InvalidContent): Character.from_tibiadata( self._load_resource(tests.tests_guild.FILE_GUILD_TIBIADATA))
def test_character_from_tibiadata_invalid_json(self): """Testing parsing an invalid JSON string""" with self.assertRaises(InvalidContent): Character.from_tibiadata("<html><b>Not a json string</b></html>")
def test_character_from_tibiadata_not_found(self): """Testing parsing a not found character""" content = self._load_resource(FILE_CHARACTER_TIBIADATA_NOT_FOUND) char = Character.from_tibiadata(content) self.assertIsNone(char)