def test_creating_normal_squad(self): units = [Soldier(RECHARGE_MIN) for x in range(UNITS_NUMBER)] squad = Squad(units) assert isinstance(squad, Squad) assert isinstance(squad.units, list)
def test_error_creating_squad(self): units = [Soldier(RECHARGE_MIN) for x in range(UNITS_NOT_ENOUGH)] with pytest.raises(UnitsNumberException): Squad(units)
def test_soldier_get_damage(self, soldier: Soldier): health_before = soldier.health soldier.damaged(DAMAGE_MIN) assert health_before != soldier.health
def test_soldier_is_alive(self, soldier: Soldier): is_alive_before_damage = soldier.is_alive() soldier.damaged(MAX_DAMAGE) assert not soldier.is_alive() assert is_alive_before_damage
def test_soldier_attack_not_success(self, soldier: Soldier): soldier.damaged(MAX_DAMAGE) assert soldier.attack_success == 0
def test_soldier_damage(self, soldier: Soldier): damage_before = soldier.damage soldier.up_experience() assert (soldier.damage - damage_before) > 0 assert isinstance(soldier.damage, float)
def test_soldier_up_experience(self, soldier: Soldier): experience_before = soldier.experience soldier.up_experience() assert (soldier.experience - experience_before) > 0 assert isinstance(soldier.experience, int)
def test_soldier_not_up_experience(self, soldier: Soldier): soldier.experience = MAX_EXPERIENCE soldier.up_experience() assert soldier.experience == MAX_EXPERIENCE
def test_creating_soldier_with_string_recharge(self): with pytest.raises(TypeError): Soldier('')
def test_creating_vehicle_with_string_recharge(self): operators = [Soldier(RECHARGE_MIN) for x in range(OPERATORS_NUMBER)] with pytest.raises(TypeError): Vehicle((0,), operators)
def test_creating_normal_vehicle(self): operators = [Soldier(RECHARGE_MIN) for x in range(OPERATORS_NUMBER)] vehicle = Vehicle(RECHARGE_VEHICLE, operators) assert isinstance(vehicle, Vehicle)
def test_creating_normal_soldier(self): soldier = Soldier(RECHARGE_MIN) assert isinstance(soldier, Soldier)
def test_vehicle_operators_less(self): operators = [Soldier(RECHARGE_MIN) for x in range(OPERATORS_NUMBER-1)] with pytest.raises(ValueError): Vehicle(RECHARGE_VEHICLE, operators)
def test_vehicle_recharge_less(self): operators = [Soldier(RECHARGE_MIN) for x in range(OPERATORS_NUMBER)] with pytest.raises(ValueError): Vehicle(RECHARGE_MIN, operators)
def create(self) -> Soldier: return Soldier(self.recharge)