-
Notifications
You must be signed in to change notification settings - Fork 1
/
commandTest.py
90 lines (73 loc) · 2.68 KB
/
commandTest.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
import unittest
from command import HTBCommand
# Here's HTBCommand "unit tests".
class HTBCommandTest(unittest.TestCase):
def testTooShort(self):
instance = HTBCommand('/time')
self.assertEqual('ERROR', instance.command)
self.assertEqual(None, instance.name)
self.assertEqual(None, instance.minutes)
def testDefault(self):
instance = HTBCommand('/timer')
self.assertEqual('NEW', instance.command)
self.assertEqual('Sprint', instance.name)
self.assertEqual(60, instance.minutes)
def testConfig(self):
instance = HTBCommand('/timer config token')
self.assertEqual('CONFIG', instance.command)
self.assertEqual('token', instance.name)
self.assertEqual(None, instance.minutes)
def testOnlyMinutes(self):
instance = HTBCommand('/timer 60')
self.assertEqual('NEW', instance.command)
self.assertEqual('Sprint', instance.name)
self.assertEqual(60, instance.minutes)
def testOnlyMinutes2(self):
instance = HTBCommand('/timer 6')
self.assertEqual('NEW', instance.command)
self.assertEqual('Sprint', instance.name)
self.assertEqual(6, instance.minutes)
def testOnlyMinutes3(self):
instance = HTBCommand('/timer 100')
self.assertEqual('NEW', instance.command)
self.assertEqual('Sprint', instance.name)
self.assertEqual(100, instance.minutes)
def testOnlyMinutes4(self):
instance = HTBCommand('/timer 0.001')
self.assertEqual(None, instance.command)
self.assertEqual(None, instance.name)
self.assertEqual(None, instance.minutes)
def testOnlyMinutes5(self):
instance = HTBCommand('/timer -1')
self.assertEqual(None, instance.command)
self.assertEqual(None, instance.name)
self.assertEqual(None, instance.minutes)
def testOnlyName(self):
instance = HTBCommand('/timer Test')
self.assertEqual('NEW', instance.command)
self.assertEqual('Test', instance.name)
self.assertEqual(60, instance.minutes)
def testNameAndMinutes(self):
instance = HTBCommand('/timer Test 5')
self.assertEqual('NEW', instance.command)
self.assertEqual('Test', instance.name)
self.assertEqual(5, instance.minutes)
def testNameAndMinutes1(self):
instance = HTBCommand('/timer Test -5')
self.assertEqual('NEW', instance.command)
self.assertEqual('Test', instance.name)
self.assertEqual(None, instance.minutes)
def testNameAndMinutes2(self):
instance = HTBCommand('/timer Test 0.001')
self.assertEqual('NEW', instance.command)
self.assertEqual('Test', instance.name)
self.assertEqual(None, instance.minutes)
def test3Things(self):
instance = HTBCommand('/timer name token 6')
self.assertEqual(None, instance.command)
self.assertEqual(None, instance.name)
self.assertEqual(None, instance.minutes)
def main():
unittest.main()
if __name__ == '__main__':
main()