forked from ironhack-labs/mini-project-vikings-en
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-testsSoldier.py
48 lines (33 loc) · 1.38 KB
/
1-testsSoldier.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
import unittest
from vikingsClasses import Soldier
from inspect import signature
class TestSoldier(unittest.TestCase):
@classmethod
def setUp(cls):
cls.strength = 150
cls.health = 300
cls.soldier = Soldier(cls.health, cls.strength)
def testConstructorSignature(self):
self.assertEqual(len(signature(Soldier).parameters), 2)
def testHealth(self):
self.assertEqual(self.soldier.health, self.health)
def testStrength(self):
self.assertEqual(self.soldier.strength, self.strength)
def testAttackShouldBeFunction(self):
self.assertEqual(callable(self.soldier.attack), True)
def testAttackHasNoParams(self):
self.assertEqual(len(signature(self.soldier.attack).parameters), 0)
def testAttackRetunsStrength(self):
self.assertEqual(self.soldier.attack(), self.strength)
def testReceivesDamage(self):
self.assertEqual(callable(self.soldier.receiveDamage), True)
def testReceivesDamageHasParams(self):
self.assertEqual(
len(signature(self.soldier.receiveDamage).parameters), 1)
def testReceiveDamageReturnNone(self):
self.assertEqual(self.soldier.receiveDamage(50), None)
def testCanReceiveDamage(self):
self.soldier.receiveDamage(50)
self.assertEqual(self.soldier.health, self.health - 50)
if __name__ == '__main__':
unittest.main()