-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_clearing.py
More file actions
46 lines (38 loc) · 1016 Bytes
/
test_clearing.py
File metadata and controls
46 lines (38 loc) · 1016 Bytes
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
from random import expovariate
from agressionSimulation import bird, clearing, forest, simulation_logger
# Generate testing objects
bird1 = bird()
bird1.setBirdChars("H", "M", 100, 200, 10)
bird2 = bird()
bird2.setBirdChars('H', "F", 100, 200, 10)
sl = simulation_logger()
sl.new_day()
cl = clearing(100, 10, 1, simulation_logger=sl)
# TODO: Testing the clearing class
# Testing the occupy function
try:
cl.occupy(None)
except TypeError as ex:
pass
try:
cl.occupy("1")
except TypeError as ex:
pass
cl.occupy(bird1)
cl.occupy(bird2)
try:
cl.occupy(bird1)
except ValueError as ex:
pass
# Testing the growth function
oldClearingCals = cl.calories
cl.growth()
assert oldClearingCals < cl.calories
# Testing the resolve function
oldClearingCals = cl.calories
oldBirdCals = [bird1.calories, bird2.calories]
assert len(cl.resolve()) == 1
assert oldClearingCals > cl.calories
assert bird1.calories > oldBirdCals[0]
assert bird2.calories > oldBirdCals[1]
print("Passed all clearing tests")