Skip to content

Commit 8509999

Browse files
committed
[Unittest creation] Creating the unittest for testing the levels of troops before merging the PR for the fix
1 parent a2457e6 commit 8509999

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/test_troop_levels.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import asyncio
2+
import unittest
3+
import os
4+
import coc
5+
6+
# Siege data was grabbed from:
7+
# https://clashofclans.fandom.com/wiki/Workshop
8+
MACHINES = {
9+
"Siege Barracks":
10+
{
11+
"release": 13,
12+
"max_at": [
13+
{
14+
"th": 13,
15+
"max": 4
16+
}
17+
]
18+
},
19+
20+
"Wall Wrecker":
21+
{
22+
"release": 12,
23+
"max_at": [
24+
{
25+
"th": 13,
26+
"max": 4
27+
}
28+
]
29+
},
30+
31+
}
32+
33+
34+
class TestTroopLevel(unittest.IsolatedAsyncioTestCase):
35+
def setUp(self) -> None:
36+
self.coc_client = coc.Client()
37+
self.machines = MACHINES
38+
39+
async def asyncSetUp(self) -> None:
40+
await asyncio.sleep(1)
41+
try:
42+
await self.coc_client.login(os.environ.get("DEV_SITE_EMAIL"),
43+
os.environ.get(
44+
"DEV_SITE_PASSWORD"))
45+
except Exception as error:
46+
self.fail(msg=error)
47+
48+
async def asyncTearDown(self) -> None:
49+
await self.coc_client.close()
50+
51+
def test_siege_machines(self):
52+
for machine_key in self.machines.keys():
53+
machine = self.machines.get(machine_key)
54+
55+
machine_obj = self.coc_client.get_troop(
56+
name=machine_key,
57+
townhall=machine.get("release") - 1)
58+
59+
self.assertEqual(0, machine_obj.get_max_level_for_townhall(12))
60+
61+
62+
if __name__ == '__main__':
63+
unittest.main()

0 commit comments

Comments
 (0)