-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
60 lines (44 loc) · 1.81 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
import unittest
from copy import deepcopy
from os import getcwd
from core import checks
from core.table import Table
class TableTest(unittest.TestCase):
t = None
def setUp(self) -> None:
self.t = Table(f"file://{getcwd()}/Scoreboard.html")
def test_services(self):
self.assertEqual(['LNKS'], self.t.service_names)
def test_teams(self):
self.assertEqual(['Tanuki'], self.t.team_names)
def test_dict(self):
self.assertEqual({'Tanuki': {'LNKS': {'status': 'down', 'fatt': 0, 'fdef': 972}}}, self.t.teams)
class CheckTest(unittest.TestCase):
cur = Table(None)
old = Table(None)
def setUp(self) -> None:
self.cur.service_names = ['TEST']
self.cur.team_names = ['t1', 't2']
self.cur.teams = {'t1': {'TEST': {'status': 'up', 'fatt': 0, 'fdef': 0}},
't2': {'TEST': {'status': 'up', 'fatt': 0, 'fdef': 0}}}
self.old = deepcopy(self.cur)
def test_fb(self):
self.cur.teams['t1']['TEST']['fatt'] = 1
self.assertEqual([('TEST', 't1')],
checks.table_fb(self.old, self.cur))
def test_tb(self):
self.cur.teams['t2']['TEST']['fatt'] = 1
self.assertEqual(['TEST'],
checks.team_bloud(self.old, self.cur, 't2'))
def test_to(self):
self.old.teams['t2']['TEST']['fdef'] = 5
self.cur.teams['t2']['TEST']['fdef'] = 4
self.assertEqual(['TEST'],
checks.team_owned(self.old, self.cur, 't2'))
def test_tc(self):
self.old.teams['t2']['TEST']['status'] = "up"
self.cur.teams['t2']['TEST']['status'] = "down"
self.assertEqual([('TEST', 'down')],
checks.team_change_status(self.old, self.cur, 't2'))
if __name__ == '__main__':
unittest.main()