Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def get_random_virus():
return get_infectable(InfectableType(random.randint(1, 3)))
def get_random_state():
return random.choice([Healthy, Dead, AsymptomaticSick, SymptomaticSick])
def get_random_state2():
return random.choice([Healthy, AsymptomaticSick, SymptomaticSick])

class ContactingTestCase(unittest.TestCase):

Expand Down Expand Up @@ -51,7 +53,38 @@ def test_antibodies(self):
t = type(p2.state)
p1.interact(p2)
self.assertEqual(type(p2.state), t)


class HealthStateTestCase(unittest.TestCase):
def setUp(self):
min_i, max_i = 0, 100 #this numbers can be arbitrary
min_j, max_j = 0, 100
n_persons = 3000
self.persons = create_persons(min_j, max_j, min_i, max_i, n_persons)
for person in self.persons:
state = get_random_state2()
if (state != Healthy):
person.virus = get_random_virus()
person.set_state(state(person))
def tearDown(self):
pass

def test_changingstate(self):
for p1 in self.persons:
p1.night_actions()
if (type(p1.state)==AsymptomaticSick):
if (p1.state.days_sick ==1):
self.assertEqual(type(p1.state),AsymptomaticSick)
p1.night_actions()
if(type(p1.state)==SymptomaticSick):
self.assertEqual(type(p1.state),SymptomaticSick)
def test_fromsick2healthy(self):
for p1 in self.persons:
p1.night_actions()
if (type(p1.state)==AsymptomaticSick):
p1.night_actions()
if(type(p1.state)==SymptomaticSick) and (p1.virus.strength >0):
self.assertEqual(type(p1.state), SymptomaticSick)
elif (p1.virus.strength <0):
self.assertEqual(type(p1.state), Healthy)

if __name__ == '__main__':
unittest.main()
unittest.main()