예제 #1
0
 def test_velocity_modifier_ship_attr_mass_zero(self):
     ship = Ship(self.mktype(attrs={
         AttrId.max_velocity: 455,
         AttrId.signature_radius: 32,
         AttrId.mass: 0}).id)
     propmod_effect = self.mkeffect(
         effect_id=EffectId.module_bonus_microwarpdrive,
         category_id=EffectCategoryId.active)
     propmod = ModuleMid(self.mktype(
         attrs={
             AttrId.mass_addition: 0,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_factor: 518,
             AttrId.speed_boost_factor: 1500000},
         effects=[propmod_effect],
         default_effect=propmod_effect).id)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity], 455)
     self.assert_log_entries(1)
     log_record = self.log[0]
     self.assertEqual(
         log_record.name,
         'eos.eve_obj.custom.propulsion_modules.modifier.python')
     self.assertEqual(log_record.levelno, logging.WARNING)
     self.assertEqual(
         log_record.msg,
         'cannot calculate propulsion speed boost due to zero ship mass')
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
예제 #2
0
 def test_fail_multiple_with_nones(self):
     # Make sure Nones are processed properly
     self.fit.ship = Ship(self.mktype(attrs={AttrId.med_slots: 3}).id)
     item_type = self.mktype()
     item1 = ModuleMid(item_type.id)
     item2 = ModuleMid(item_type.id)
     item3 = ModuleMid(item_type.id)
     self.fit.modules.mid.place(1, item1)
     self.fit.modules.mid.place(4, item2)
     self.fit.modules.mid.place(6, item3)
     # Action
     error1 = self.get_error(item1, Restriction.mid_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error2)
     self.assertEqual(error2.used, 7)
     self.assertEqual(error2.total, 3)
     # Action
     error3 = self.get_error(item2, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error3)
     self.assertEqual(error3.used, 7)
     self.assertEqual(error3.total, 3)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #3
0
 def test_velocity_modifier_isolation(self):
     # When velocity cannot be modified due to errors, sig and mass still
     # should be successfully modified
     ship = self.make_ship()
     propmod_effect = self.mkeffect(
         effect_id=EffectId.module_bonus_microwarpdrive,
         category_id=EffectCategoryId.active)
     propmod = ModuleMid(
         self.mktype(attrs={
             AttrId.mass_addition: 500000,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_boost_factor: 1500000
         },
                     effects=[propmod_effect],
                     default_effect=propmod_effect).id)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity], 455)
     self.assertAlmostEqual(ship.attrs[AttrId.signature_radius], 163.2)
     self.assertAlmostEqual(ship.attrs[AttrId.mass], 1550000)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #4
0
 def test_use_multiple_with_none(self):
     self.fit.modules.mid.place(1, ModuleMid(self.mktype().id))
     self.fit.modules.mid.place(3, ModuleMid(self.mktype().id))
     # Verification
     self.assertEqual(self.fit.stats.mid_slots.used, 4)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #5
0
 def test_module_mid_pass_effect_disabled(self):
     effect = self.mkeffect(effect_id=EffectId.med_power,
                            category_id=EffectCategoryId.passive)
     item = ModuleMid(
         self.mktype(category_id=TypeCategoryId.module,
                     effects=[effect]).id)
     item.set_effect_mode(effect.id, EffectMode.force_stop)
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.item_class)
     # Verification
     self.assertIsNone(error)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #6
0
 def test_use_item_class_other(self):
     self.fit.modules.mid.place(3, ModuleMid(self.mktype().id))
     # Verification
     self.assertEqual(self.fit.stats.high_slots.used, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #7
0
 def test_module_mid_pass_effect_disabled(self):
     effect = self.mkeffect(
         effect_id=EffectId.med_power,
         category_id=EffectCategoryId.passive)
     item = ModuleMid(self.mktype(
         category_id=TypeCategoryId.module,
         effects=[effect]).id)
     item.set_effect_mode(effect.id, EffectMode.force_stop)
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.item_class)
     # Verification
     self.assertIsNone(error)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #8
0
 def setUp(self):
     ContainerTestCase.setUp(self)
     self.mod_high1 = ModuleHigh(self.mktype().id)
     self.mod_high2 = ModuleHigh(self.mktype().id)
     self.mod_mid1 = ModuleMid(self.mktype().id)
     self.mod_mid2 = ModuleMid(self.mktype().id)
     self.mod_low1 = ModuleLow(self.mktype().id)
     self.mod_low2 = ModuleLow(self.mktype().id)
     self.mod_low3 = ModuleLow(self.mktype().id)
     self.fit = Fit()
     self.fit.modules.high.place(0, self.mod_high1)
     self.fit.modules.high.place(3, self.mod_high2)
     self.fit.modules.mid.place(1, self.mod_mid1)
     self.fit.modules.mid.place(4, self.mod_mid2)
     self.fit.modules.low.place(0, self.mod_low1)
     self.fit.modules.low.place(4, self.mod_low2)
예제 #9
0
 def test_use_item_not_loaded(self):
     self.fit.modules.mid.append(ModuleMid(self.allocate_type_id()))
     # Verification
     self.assertEqual(self.fit.stats.mid_slots.used, 1)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #10
0
 def test_use_item_class_other(self):
     self.fit.modules.mid.append(
         ModuleMid(self.mktype().id, state=State.online))
     # Verification
     self.assertEqual(self.fit.stats.launched_drones.used, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #11
0
 def test_pass_greater(self):
     self.fit.ship = Ship(self.mktype(attrs={AttrId.med_slots: 5}).id)
     item_type = self.mktype()
     item1 = ModuleMid(item_type.id)
     item2 = ModuleMid(item_type.id)
     self.fit.modules.mid.append(item1)
     self.fit.modules.mid.append(item2)
     # Action
     error1 = self.get_error(item1, Restriction.mid_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.mid_slot)
     # Verification
     self.assertIsNone(error2)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #12
0
 def test_module_mid_fail_not_loaded(self):
     item = ModuleMid(self.allocate_type_id())
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.loaded_item)
     # Verification
     self.assertIsNotNone(error)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #13
0
 def test_velocity_modifier_propmod_attr_thrust_absent(self):
     ship = self.make_ship()
     propmod_effect = self.mkeffect(
         effect_id=EffectId.module_bonus_microwarpdrive,
         category_id=EffectCategoryId.active)
     propmod = ModuleMid(self.mktype(
         attrs={
             AttrId.mass_addition: 500000,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_factor: 518},
         effects=[propmod_effect],
         default_effect=propmod_effect).id)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity], 455)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #14
0
 def test_module_mid(self):
     module = ModuleMid(self.make_item_types())
     self.fit.modules.mid.append(module)
     self.assertAlmostEqual(module.attrs[self.tgt_attr_id], 18)
     # Action
     self.fit.solar_system.source = 'src2'
     # Verification
     self.assertAlmostEqual(module.attrs[self.tgt_attr_id], 14)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #15
0
 def make_prop_mod(self, effect_id):
     effect = self.mkeffect(effect_id=effect_id,
                            category_id=EffectCategoryId.active)
     return ModuleMid(
         self.mktype(attrs={
             AttrId.mass_addition: 500000,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_factor: 518,
             AttrId.speed_boost_factor: 1500000
         },
                     effects=[effect],
                     default_effect=effect).id)
예제 #16
0
 def test_velocity_modifier_propmod_attr_thrust_absent(self):
     ship = self.make_ship()
     propmod_effect = self.mkeffect(
         effect_id=EffectId.module_bonus_microwarpdrive,
         category_id=EffectCategoryId.active)
     propmod = ModuleMid(
         self.mktype(attrs={
             AttrId.mass_addition: 500000,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_factor: 518
         },
                     effects=[propmod_effect],
                     default_effect=propmod_effect).id)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity], 455)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #17
0
 def test_item_outside_type_failure(self):
     fit = Fit()
     item = ModuleMid(self.mktype().id)
     # Action
     with self.assertRaises(TypeError):
         fit.modules.high.place(2, item)
     # Verification
     self.assertIs(len(fit.modules.high), 0)
     fit.modules.mid.place(0, item)
     # Cleanup
     self.assert_item_buffers_empty(item)
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)
예제 #18
0
 def test_fail_ship_not_loaded(self):
     self.fit.ship = Ship(self.allocate_type_id())
     item = ModuleMid(self.mktype().id)
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #19
0
 def test_fail_multiple(self):
     # Check that error works for multiple items, and raised only for those
     # which lie out of bounds
     self.fit.ship = Ship(self.mktype(attrs={AttrId.med_slots: 1}).id)
     item_type = self.mktype()
     item1 = ModuleMid(item_type.id)
     item2 = ModuleMid(item_type.id)
     self.fit.modules.mid.append(item1)
     self.fit.modules.mid.append(item2)
     # Action
     error1 = self.get_error(item1, Restriction.mid_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error2)
     self.assertEqual(error2.used, 2)
     self.assertEqual(error2.total, 1)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #20
0
 def test_fail_item_not_loaded(self):
     # Item still counts even when it's not loaded
     self.fit.ship = Ship(self.mktype(attrs={AttrId.med_slots: 0}).id)
     item = ModuleMid(self.allocate_type_id())
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #21
0
 def test_fail_ship_absent(self):
     # When stats module does not specify total slot quantity, make sure it's
     # assumed to be 0
     item = ModuleMid(self.mktype().id)
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #22
0
 def test_module_mid_fail_category_other(self):
     effect = self.mkeffect(effect_id=EffectId.med_power,
                            category_id=EffectCategoryId.passive)
     item = ModuleMid(self.mktype(category_id=1008, effects=[effect]).id)
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.item_class)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.item_class, ModuleMid)
     self.assertCountEqual(error.allowed_classes, [])
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #23
0
 def test_velocity_modifier_isolation(self):
     # When velocity cannot be modified due to errors, sig and mass still
     # should be successfully modified
     ship = self.make_ship()
     propmod_effect = self.mkeffect(
         effect_id=EffectId.module_bonus_microwarpdrive,
         category_id=EffectCategoryId.active)
     propmod = ModuleMid(self.mktype(
         attrs={
             AttrId.mass_addition: 500000,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_boost_factor: 1500000},
         effects=[propmod_effect],
         default_effect=propmod_effect).id)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity], 455)
     self.assertAlmostEqual(ship.attrs[AttrId.signature_radius], 163.2)
     self.assertAlmostEqual(ship.attrs[AttrId.mass], 1550000)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #24
0
 def test_fail_single(self):
     # Check that error is raised when quantity of used slots exceeds slot
     # quantity provided by ship
     self.fit.ship = Ship(self.mktype(attrs={AttrId.med_slots: 0}).id)
     item = ModuleMid(self.mktype().id)
     self.fit.modules.mid.append(item)
     # Action
     error = self.get_error(item, Restriction.mid_slot)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.used, 1)
     self.assertEqual(error.total, 0)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
예제 #25
0
 def test_velocity_modifier_ship_attr_mass_zero(self):
     ship = Ship(
         self.mktype(
             attrs={
                 AttrId.max_velocity: 455,
                 AttrId.signature_radius: 32,
                 AttrId.mass: 0
             }).id)
     propmod_effect = self.mkeffect(
         effect_id=EffectId.module_bonus_microwarpdrive,
         category_id=EffectCategoryId.active)
     propmod = ModuleMid(
         self.mktype(attrs={
             AttrId.mass_addition: 0,
             AttrId.signature_radius_bonus: 410,
             AttrId.speed_factor: 518,
             AttrId.speed_boost_factor: 1500000
         },
                     effects=[propmod_effect],
                     default_effect=propmod_effect).id)
     propmod.state = State.active
     self.fit.ship = ship
     self.fit.modules.mid.append(propmod)
     # Verification
     self.assertAlmostEqual(ship.attrs[AttrId.max_velocity], 455)
     self.assert_log_entries(1)
     log_record = self.log[0]
     self.assertEqual(
         log_record.name,
         'eos.eve_obj.custom.propulsion_modules.modifier.python')
     self.assertEqual(log_record.levelno, logging.WARNING)
     self.assertEqual(
         log_record.msg,
         'cannot calculate propulsion speed boost due to zero ship mass')
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
예제 #26
0
 def test_item_onto_none_type_failure(self):
     fit = Fit()
     item1 = ModuleHigh(self.mktype().id)
     item2 = ModuleMid(self.mktype().id)
     fit.modules.high.insert(1, item1)
     # Action
     with self.assertRaises(TypeError):
         fit.modules.high.place(0, item2)
     # Verification
     self.assertIs(len(fit.modules.high), 2)
     self.assertIsNone(fit.modules.high[0])
     self.assertIs(fit.modules.high[1], item1)
     fit.modules.mid.place(0, item2)
     # Cleanup
     self.assert_item_buffers_empty(item1)
     self.assert_item_buffers_empty(item2)
     self.assert_solsys_buffers_empty(fit.solar_system)
     self.assert_log_entries(0)