def test_get_damage(self): print("test_get_damage") self.squad._units = [Soldier(), Soldier(), Soldier()] self.squad.get_damage(12.6) for unit in self.squad._units: assert unit._health == 95.8 self.squad.get_damage(21) for unit in self.squad._units: assert unit._health == 88.8
def test_incrs_experience(self): print("test_incrs_experience") self.squad._units = [Soldier(), Soldier(), Soldier()] self.squad._units[0]._experience = 4.8 self.squad._units[1]._experience = 9.5 self.squad._units[2]._experience = 12.64 self.squad.incrs_unit_experience() assert self.squad._units[0]._experience == 4.81 assert self.squad._units[1]._experience == 9.51 assert self.squad._units[2]._experience == 12.65
def test_incrs_experience(self): print("test_incrs_experience") self.vehicle.operators = [Soldier(), Soldier()] self.vehicle.operators[0].experience = 44 self.vehicle.operators[0].incrs_experience() assert self.vehicle.operators[0].experience == 44.01 self.vehicle.operators[1].experience = 12.6 self.vehicle.operators[1].incrs_experience() assert self.vehicle.operators[1].experience == 12.61 self.vehicle.operators[0].experience = 50 self.vehicle.operators[0].incrs_experience() assert self.vehicle.operators[0].experience == 50
def test_calc_operator_dmg(self): print("test_calc_operator_dmg") self.vehicle.operators = [Soldier(), Soldier()] self.vehicle.operators[0].health = 0 self.vehicle.calc_operator_dmg(5.7, 0, 20) assert self.vehicle.operators[0].health == 0 self.vehicle.operators[1].health = 23.4 self.vehicle.calc_operator_dmg(12.1, 1, 10) assert self.vehicle.operators[1].health == 22.189999999999998 self.vehicle.operators[0].health = 40 self.vehicle.calc_operator_dmg(17, 0, 40) assert self.vehicle.operators[0].health == 33.2
def test_check_formation_is_active(self): print('test_check_formation_is_active') self.formation._units = [ Soldier(), Vehicle(), Soldier(), Soldier(), Vehicle() ] self.formation._units[0]._active = False self.formation._units[1]._active = False assert self.formation.check_formation_is_active() is True self.formation._units[0]._active = False self.formation._units[1]._active = False self.formation._units[2]._active = False assert self.formation.check_formation_is_active() is False
def test_get_damage(self): print("test_get_damage") self.vehicle.operators = [Soldier(), Soldier(), Soldier()] self.vehicle.operators[1].health = -1 self.vehicle.get_damage(5.7) assert len(self.vehicle.operators) == 2 self.vehicle.operators[0].health = 66 self.vehicle.operators[1].health = 12.4 self.vehicle.get_damage(3.3) assert self.vehicle.health == 57.73333333333333 self.vehicle.operators[0].health = -2 self.vehicle.operators[1].health = -2.4 self.vehicle.get_damage(6.8) assert self.vehicle.health == -1
def test_to_damage(self): print("test_to_damage") self.vehicle.last_attack_time = self.vehicle._timer.get_current_time() self.vehicle.last_attack_time -= self.vehicle.recharge self.vehicle.operators = [Soldier(), Soldier(), Soldier()] self.vehicle.operators[0].experience = 6.3 self.vehicle.operators[1].experience = 8.6 self.vehicle.operators[2].experience = 4.5 assert self.vehicle.to_damage() == 0.294 self.vehicle.last_attack_time = self.vehicle._timer.get_current_time() self.vehicle.last_attack_time -= self.vehicle.recharge self.vehicle.operators[0].experience = 12.3 self.vehicle.operators[1].experience = 34.9 self.vehicle.operators[2].experience = 6.1 assert self.vehicle.to_damage() == 0.633
def test_to_damage(self): print("test_to_damage") self.squad._units = [Soldier(), Soldier(), Soldier(), Soldier(), Soldier()] self.squad._units[0]._experience = 10 self.squad._units[0]._last_attack_time = self.squad._units[0]._last_attack_time - self.squad._units[0]._recharge self.squad._units[1]._experience = 14 self.squad._units[1]._last_attack_time = self.squad._units[1]._last_attack_time - self.squad._units[1]._recharge self.squad._units[2]._experience = 8 self.squad._units[2]._last_attack_time = self.squad._units[2]._last_attack_time - self.squad._units[2]._recharge self.squad._units[3]._experience = 12 self.squad._units[3]._last_attack_time = self.squad._units[3]._last_attack_time - self.squad._units[3]._recharge self.squad._units[4]._experience = 9 self.squad._units[4]._last_attack_time = self.squad._units[4]._last_attack_time - self.squad._units[4]._recharge assert self.squad.to_damage() == 0.78 self.squad._units = [Soldier(), Soldier(), Soldier()] self.squad._units[0]._experience = 40.5 self.squad._units[0]._last_attack_time = self.squad._units[0]._last_attack_time - self.squad._units[0]._recharge self.squad._units[1]._experience = 12 self.squad._units[1]._last_attack_time = self.squad._units[1]._last_attack_time - self.squad._units[1]._recharge self.squad._units[2]._experience = 45 self.squad._units[2]._last_attack_time = self.squad._units[2]._last_attack_time - self.squad._units[2]._recharge assert self.squad.to_damage() == 1.125
def test_new_unit(self): print("test_new_unit") assert isinstance(Soldier.new_unit(), Soldier)
def setup(self): print("setup") self.soldier = Soldier()
class TestSoldier(): def setup(self): print("setup") self.soldier = Soldier() def test_to_attack(self): print("test_to_attack") assert isinstance(self.soldier.to_attack(), float) assert self.soldier.to_attack() > 0 def test_to_damage(self): print("test_to_damage") self.soldier.last_attack_time = self.soldier._timer.get_current_time() self.soldier.last_attack_time -= self.soldier.recharge self.soldier.experience = 7 assert self.soldier.to_damage() == 0.12000000000000001 self.soldier.last_attack_time -= self.soldier.recharge self.soldier.experience = 25 assert self.soldier.to_damage() == 0.3 def test_get_damage(self): print("test_get_damage") self.soldier.health = 90 self.soldier.get_damage(10.5) assert self.soldier.health == 79.5 self.soldier.health = 40.5 self.soldier.get_damage(3.4) assert self.soldier.health == 37.1 self.soldier.health = -2.5 self.soldier.get_damage(6.4) assert self.soldier.health == -2.5 def test_incrs_experience(self): print("test_incrs_experience") self.soldier.experience = 44 self.soldier.incrs_experience() assert self.soldier.experience == 44.01 self.soldier.experience = 12.6 self.soldier.incrs_experience() assert self.soldier.experience == 12.61 self.soldier.experience = 50 self.soldier.incrs_experience() assert self.soldier.experience == 50 def test_new_unit(self): print("test_new_unit") assert isinstance(Soldier.new_unit(), Soldier)