Ejemplo n.º 1
0
    def test_not_infected_with_mortality_1_dont_die(self):
        person = Person()
        propagator = Propagator([person], daily_mortality=1.0)

        propagator.step()

        self.assertFalse(person.dead)
Ejemplo n.º 2
0
    def test_step_one_infected_unity_rate_infects_other(self):
        self.two_in_contact[0].infected = True
        propagator = Propagator(self.two_in_contact, rate=1.0)

        propagator.step()

        self.assertTrue(self.two_in_contact[1].infected)
Ejemplo n.º 3
0
    def test_step_with_two_in_contact_and_zero_rate_does_nothing(self):
        propagator = Propagator(self.two_in_contact, rate=0.0)

        propagator.step()

        self.assertFalse(self.two_in_contact[0].infected)
        self.assertFalse(self.two_in_contact[1].infected)
Ejemplo n.º 4
0
    def test_all_infected_die_with_mortality_1(self):
        person = Person()
        person.infected = True
        propagator = Propagator([person], daily_mortality=1.0)

        propagator.step()

        self.assertTrue(person.dead)
Ejemplo n.º 5
0
    def test_none_in_contact_do_not_infect(self):
        people = [Person(), Person()]
        people[0].infected = True
        propagator = Propagator(people, rate=1.0)

        propagator.step()

        self.assertFalse(people[1].infected)
Ejemplo n.º 6
0
    def test_step_half_rate_infects_other_with_rng_zero(self, mock_random):
        mock_random.return_value = 0.0
        self.two_in_contact[0].infected = True
        propagator = Propagator(self.two_in_contact, rate=0.5)

        propagator.step()

        self.assertTrue(self.two_in_contact[1].infected)
Ejemplo n.º 7
0
    def test_all_infected_die_with_mortality_one_tenth_and_rng_0(self, mock_random):
        mock_random.return_value = 0.0
        person = Person()
        person.infected = True
        propagator = Propagator([person], daily_mortality=0.1)

        propagator.step()

        self.assertTrue(person.dead)
Ejemplo n.º 8
0
    def test_those_that_die_do_not_recover(self, mock_random):
        mock_random.return_value = 0.0
        person = Person()
        person.infected = True
        propagator = Propagator([person], daily_mortality=1.0, infection_length=1)

        propagator.step()

        self.assertFalse(person.recovered)
Ejemplo n.º 9
0
    def test_the_dead_do_not_infect(self, mock_random):
        mock_random.return_value = 0.0
        self.two_in_contact[0].dead = True
        self.two_in_contact[0].infected = True
        propagator = Propagator(self.two_in_contact, daily_mortality=1.0, rate=1.0)

        propagator.step()

        self.assertFalse(self.two_in_contact[1].infected)
Ejemplo n.º 10
0
    def test_those_that_die_are_not_considered_infected(self, mock_random):
        mock_random.return_value = 0.0
        person = Person()
        person.infected = True
        propagator = Propagator([person], daily_mortality=1.0)

        propagator.step()

        self.assertFalse(person.infected)
Ejemplo n.º 11
0
    def test_results_has_length_of_steps_with_one_step(self):
        propagator = Propagator(self.two_in_contact)

        propagator.step()

        self.assertEqual(1, len(propagator.results.day))