def test_no_birth_if_baby_weight_is_zero(self, example_properties_w_40, mocker): """ Tests birth_process method. Asserts that no baby is born if the baby's birth weight is equal to zero. """ mocker.patch('numpy.random.normal', return_value=0) animal = Animal(example_properties_w_40) animal.find_fitness() assert animal.birth_process(num_animals=6) is None
def test_no_birth_when_mothers_weight_small(self, example_properties_w_40, mocker): """ Asserts that no baby is born from running birth_process when mother's weight is less than xi times baby's weight. """ mocker.patch('numpy.random.normal', return_value=50) animal = Animal(example_properties_w_40) animal.find_fitness() baby_weight = animal.birth_process(num_animals=6) assert baby_weight is None
def test_mother_loses_weight_after_birth(self, example_properties_w_40, mocker): """ Test birth_process method. Asserts that mother loses weight equal to xi * baby's weight after giving birth. """ mocker.patch('numpy.random.normal', return_value=5.5) animal = Animal(example_properties_w_40) animal.find_fitness() initial_weight = animal.weight birth_weight = animal.birth_process(num_animals=6) assert animal.weight == initial_weight - \ (animal.params['xi'] * birth_weight)
def test_baby_weight_returned_when_mothers_weight_large_enough( self, example_properties_w_40, mocker): """ After running birth_process, we check that a birth took place by testing if baby's weight is a float of given value and that the baby's weight times xi was smaller than the mother's weight. """ mocker.patch('numpy.random.normal', return_value=5.5) animal = Animal(example_properties_w_40) animal.find_fitness() baby_weight = animal.birth_process(num_animals=6) assert type(baby_weight) is float assert baby_weight == 5.5 assert animal.weight > baby_weight * animal.params['xi']