This repository was archived by the owner on Apr 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.py
169 lines (142 loc) · 5.51 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import unittest
from api_wrapper import Collections, Collection, Clans, Clan, Exists, Rap, APIRequest, APIResponse
from api_wrapper.subclasses import Sort, SortObject, Member, Battle, PetExist, PetType, PetRap, BattleMember
class TestCollections(unittest.TestCase):
def test_get_data(self):
collections = Collections()
data = collections.get_data()
self.assertIsInstance(data, list)
def test_get_status(self):
collections = Collections()
status = collections.get_status()
self.assertIsInstance(status, str)
class TestCollection(unittest.TestCase):
def test_get_data(self):
collection = Collection("Pets")
data = collection.get_data()
self.assertIsInstance(data, list)
def test_get_info_by_name(self):
collection = Collection("Pets")
pet_info = collection.get_info_by_name("Flamingo")
self.assertIsNotNone(pet_info)
def test_get_status(self):
collection = Collection("Pets")
status = collection.get_status()
self.assertIsInstance(status, str)
class TestClans(unittest.TestCase):
def test_get_clans(self):
clans = Clans()
clan_list = clans.get_clans()
self.assertIsInstance(clan_list, list)
self.assertIsInstance(clan_list[0], Clan)
def test_get_data(self):
clans = Clans()
data = clans.get_data()
self.assertIsInstance(data, list)
def test_get_status(self):
clans = Clans()
status = clans.get_status()
self.assertIsInstance(status, str)
class TestClan(unittest.TestCase):
def test_get_data(self):
clan = Clan("EXP")
data = clan.get_data()
self.assertIsInstance(data, dict)
def test_get_status(self):
clan = Clan("EXP")
status = clan.get_status()
self.assertIsInstance(status, str)
class TestExists(unittest.TestCase):
def test_get_data(self):
exists = Exists()
data = exists.get_data()
self.assertIsInstance(data, list)
def test_search_for_pet(self):
exists = Exists()
pet_info = exists.search_for_pet("Huge Happy Rock")
self.assertIsNotNone(pet_info)
def test_get_status(self):
exists = Exists()
status = exists.get_status()
self.assertIsInstance(status, str)
class TestRap(unittest.TestCase):
def test_get_data(self):
rap = Rap()
data = rap.get_data()
self.assertIsInstance(data, list)
def test_search_for_pet(self):
rap = Rap()
pet_info = rap.search_for_pet("Huge Happy Rock")
self.assertIsNotNone(pet_info)
def test_get_status(self):
rap = Rap()
status = rap.get_status()
self.assertIsInstance(status, str)
class TestSubclasses(unittest.TestCase):
def test_sort_object(self):
sort_obj = SortObject("Points")
self.assertEqual(str(sort_obj), "Points")
def test_member(self):
member_data = {"Donated": 100, "Points": 50, "UserID": 123, "PermissionLevel": 2, "JoinTime": 1679012345}
member = Member(member_data)
self.assertEqual(member.Donated, 100)
self.assertEqual(member.Points, 50)
def test_battle(self):
battle_data = {
"Name": "DecemberActiveHugePets",
"ProcessedAwards": True,
"AwardUserIDs": [1331231231, 1231313],
"BattleID": "DecemberActiveHugePets",
"PointsEarned": 231313,
"PointContributions": [{"UserID": 2313123, "Points": 2313123}],
"EarnedMedal": None
}
battle = Battle(battle_data)
self.assertEqual(battle.Name, "DecemberActiveHugePets")
def test_pet_exist(self):
pet_exist_data = {
"Category": "Pet",
"ConfigData": {
"Id": "Huge Happy Rock",
"Pt": None,
"Sh": True
},
"Value": 999
}
pet_exist = PetExist(pet_exist_data)
self.assertEqual(pet_exist.Category, "Pet")
self.assertEqual(pet_exist.IsShiny, True)
self.assertEqual(pet_exist.Variation, "Normal")
self.assertEqual(pet_exist.ExistCount, 999)
def test_pet_rap(self):
pet_rap_data = {
"Category": "Pet",
"ConfigData": {
"Id": "Huge Happy Rock",
"Pt": 1,
"Sh": True
},
"Value": 1234
}
pet_rap = PetRap(pet_rap_data)
self.assertEqual(pet_rap.Category, "Pet")
self.assertEqual(pet_rap.IsShiny, True)
self.assertEqual(pet_rap.Variation, "Golden")
self.assertEqual(pet_rap.Rap, 1234)
class TestSearchFunctions(unittest.TestCase):
def test_collection_get_info_by_name(self):
collection = Collection("Pets")
pet_info = collection.get_info_by_name("Huge Happy Rock")
self.assertIsNotNone(pet_info)
def test_exists_search_for_pet(self):
exists = Exists()
pet_info = exists.search_for_pet("Huge Happy Rock")
self.assertIsNotNone(pet_info)
self.assertEqual(pet_info.Id, "Huge Happy Rock")
def test_rap_search_for_pet(self):
rap = Rap()
pet_info = rap.search_for_pet("Huge Happy Rock")
self.assertIsNotNone(pet_info)
self.assertEqual(pet_info.Id, "Huge Happy Rock")
if __name__ == "__main__":
unittest.main()