Beispiel #1
0
 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)
Beispiel #2
0
 def test_error_creating_squad(self):
     units = [Soldier(RECHARGE_MIN) for x in range(UNITS_NOT_ENOUGH)]
     with pytest.raises(UnitsNumberException):
         Squad(units)
Beispiel #3
0
 def test_soldier_get_damage(self, soldier: Soldier):
     health_before = soldier.health
     soldier.damaged(DAMAGE_MIN)
     assert health_before != soldier.health
Beispiel #4
0
 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
Beispiel #5
0
 def test_soldier_attack_not_success(self, soldier: Soldier):
     soldier.damaged(MAX_DAMAGE)
     assert soldier.attack_success == 0
Beispiel #6
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)
Beispiel #7
0
 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)
Beispiel #8
0
 def test_soldier_not_up_experience(self, soldier: Soldier):
     soldier.experience = MAX_EXPERIENCE
     soldier.up_experience()
     assert soldier.experience == MAX_EXPERIENCE
Beispiel #9
0
 def test_creating_soldier_with_string_recharge(self):
     with pytest.raises(TypeError):
         Soldier('')
Beispiel #10
0
 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)
Beispiel #11
0
 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)
Beispiel #12
0
 def test_creating_normal_soldier(self):
     soldier = Soldier(RECHARGE_MIN)
     assert isinstance(soldier, Soldier)
Beispiel #13
0
 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)
Beispiel #14
0
 def test_vehicle_recharge_less(self):
     operators = [Soldier(RECHARGE_MIN) for x in range(OPERATORS_NUMBER)]
     with pytest.raises(ValueError):
         Vehicle(RECHARGE_MIN, operators)
Beispiel #15
0
 def create(self) -> Soldier:
     return Soldier(self.recharge)