def test_exp_level(self): data = {"expLevel": 241} member = ClanMember(data=data, client=None) self.assertEqual(member.exp_level, data["expLevel"]) member2 = ClanMember(data=MOCK_CLAN_MEMBER, client=None) self.assertIsInstance(member2.exp_level, int)
def test_league(self): data = { "league": { "id": 29000022, "name": "Legend League", } } member = ClanMember(data=data, client=None) league = League(data=data["league"], client=None) self.assertEqual(member.league, league) self.assertIsInstance(member.league, League)
def test_role(self): data = [{ "role": "member" }, { "role": "admin" }, { "role": "coLeader" }, { "role": "leader" }] for case in data: member = ClanMember(data=case, client=None) role = Role(case["role"]) self.assertEqual(member.role, role) self.assertIsInstance(member.role, Role) role_readable = str(role) self.assertIsInstance(role_readable, str) self.assertNotEqual(role_readable, role)
def test_clan(self): data = { "clan": { "tag": "#8J8QJ2LV", "name": "Reddit Ace", "clanLevel": 18, "badgeUrls": { "small": "https://api-assets.clashofclans.com/badges/70/thXuucdocdtfUts55bsAoGfQ0P8ghwLezzeG-UUajp0.png", "large": "https://api-assets.clashofclans.com/badges/512/thXuucdocdtfUts55bsAoGfQ0P8ghwLezzeG-UUajp0.png", "medium": "https://api-assets.clashofclans.com/badges/200/thXuucdocdtfUts55bsAoGfQ0P8ghwLezzeG-UUajp0.png", }, } } member = ClanMember(data=data, client=None) clan = PlayerClan(data=data["clan"], client=None) self.assertEqual(member.clan, clan) self.assertIsInstance(member.clan, PlayerClan)
def test_received(self): data = [{"donationsReceived": 9876}, {"donationsReceived": 0}, {}] for case in data: member = ClanMember(data=case, client=None) self.assertEqual(member.received, case.get("donationsReceived"))
def test_donations(self): data = [{"donations": 55}, {"donations": 0}, {}] for case in data: member = ClanMember(data=case, client=None) self.assertEqual(member.donations, case.get("donations"))
def test_clan_previous_rank(self): data = [{"previousClanRank": 14}, {"previousClanRank": 4}, {}] for case in data: member = ClanMember(data=case, client=None) self.assertEqual(member.clan_previous_rank, case.get("previousClanRank"))
def test_versus_trophies(self): data = [{"versusTrophies": 4433}, {"versusTrophies": 0}, {}] for case in data: member = ClanMember(data=case, client=None) self.assertEqual(member.versus_trophies, case.get("versusTrophies"))
def test_trophies(self): data = [{"trophies": 5432}, {"trophies": 0}, {}] for case in data: member = ClanMember(data=case, client=None) self.assertEqual(member.trophies, case.get("trophies"))