def setUp(self): CustomizationTestCase.setUp(self) # Create character self.mkattr(attr_id=AttrId.missile_dmg_mult) self.fit.character = Character(self.mktype( type_id=TypeId.character_static, group_id=TypeGroupId.character, attrs={AttrId.missile_dmg_mult: 1}).id) # Create Ballistic Control System item bcs_src_attr = self.mkattr() bcs_mod = self.mkmod( affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.character, affectee_attr_id=AttrId.missile_dmg_mult, operator=ModOperator.post_percent, affector_attr_id=bcs_src_attr.id) bcs_effect = self.mkeffect( category_id=EffectCategoryId.online, modifiers=[bcs_mod]) online_effect = self.mkeffect( effect_id=EffectId.online, category_id=EffectCategoryId.active) bcs_type = self.mktype( attrs={bcs_src_attr.id: 10}, effects=[bcs_effect, online_effect]) bcs = ModuleLow(bcs_type.id, state=State.online) self.fit.modules.low.append(bcs) # Create launcher self.launcher = ModuleHigh(self.mktype()) self.fit.modules.high.append(self.launcher)
def test_output_char_attr_absent(self): self.fit.character = Character(self.mktype().id) # Verification self.assertEqual(self.fit.stats.launched_drones.total, 0) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_output_char_not_loaded(self): self.fit.character = Character(self.allocate_type_id()) # Verification self.assertEqual(self.fit.stats.launched_drones.total, 0) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_character_pass(self): item = Character(self.mktype(group_id=TypeGroupId.character).id) self.fit.character = 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)
def test_character_pass_loaded(self): item = Character(self.mktype().id) self.fit.character = item # Action error = self.get_error(item, Restriction.loaded_item) # Verification self.assertIsNone(error) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_character_fail_not_loaded(self): item = Character(self.allocate_type_id()) self.fit.character = 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)
def test_character(self): character = Character(self.make_item_types()) self.fit.character = character self.assertAlmostEqual(character.attrs[self.tgt_attr_id], 18) # Action self.fit.solar_system.source = 'src2' # Verification self.assertAlmostEqual(character.attrs[self.tgt_attr_id], 14) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_pass_item_class_other(self): self.fit.character = Character(self.mktype( attrs={AttrId.max_active_drones: 0}).id) item = ModuleHigh(self.mktype().id, state=State.online) self.fit.modules.high.append(item) # Action error = self.get_error(item, Restriction.launched_drone) # Verification self.assertIsNone(error) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_character_fail_group_other(self): item = Character(self.mktype(group_id=1008).id) self.fit.character = item # Action error = self.get_error(item, Restriction.item_class) # Verification self.assertIsNotNone(error) self.assertEqual(error.item_class, Character) self.assertCountEqual(error.allowed_classes, []) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_pass_state(self): self.fit.character = Character(self.mktype( attrs={AttrId.max_active_drones: 0}).id) item = Drone(self.mktype().id, state=State.offline) self.fit.drones.add(item) # Action error = self.get_error(item, Restriction.launched_drone) # Verification self.assertIsNone(error) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_fail_char_not_loaded(self): self.fit.character = Character(self.allocate_type_id()) item = Drone(self.mktype().id, state=State.online) self.fit.drones.add(item) # Action error = self.get_error(item, Restriction.launched_drone) # 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)
def test_fail_single(self): # Check that error is raised when quantity of used slots exceeds slot # quantity provided by char self.fit.character = Character(self.mktype( attrs={AttrId.max_active_drones: 0}).id) item = Drone(self.mktype().id, state=State.online) self.fit.drones.add(item) # Action error = self.get_error(item, Restriction.launched_drone) # 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)
def test_character(self): influence_src = Character(self.influence_src_type.id) influence_tgt = Implant(self.mktype( group_id=35, attrs={self.tgt_attr.id: 100}).id) self.fit.implants.add(influence_tgt) # Action self.fit.character = influence_src # Verification self.assertAlmostEqual(influence_tgt.attrs[self.tgt_attr.id], 120) # Action self.fit.character = None # Verification self.assertAlmostEqual(influence_tgt.attrs[self.tgt_attr.id], 100) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_not_owner_modifiable(self): influence_src = Character(self.influence_src_type.id) influence_tgt = Implant( self.mktype( attrs={ self.tgt_attr.id: 100, AttrId.required_skill_1: 56, AttrId.required_skill_1_level: 1 }).id) self.fit.implants.add(influence_tgt) # Action self.fit.character = influence_src # Verification self.assertAlmostEqual(influence_tgt.attrs[self.tgt_attr.id], 100) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_character(self): influence_tgt = Character( self.mktype(attrs={ self.tgt_attr.id: 100 }).id) self.fit.character = influence_tgt # Action self.fit.rigs.add(self.influence_src) # Verification self.assertAlmostEqual(influence_tgt.attrs[self.tgt_attr.id], 120) # Action self.fit.rigs.remove(self.influence_src) # Verification self.assertAlmostEqual(influence_tgt.attrs[self.tgt_attr.id], 100) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_output(self): src_attr = self.mkattr() modifier = self.mkmod( affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.self, affectee_attr_id=AttrId.max_active_drones, operator=ModOperator.post_mul, affector_attr_id=src_attr.id) mod_effect = self.mkeffect( category_id=EffectCategoryId.passive, modifiers=[modifier]) self.fit.character = Character(self.mktype( attrs={AttrId.max_active_drones: 3, src_attr.id: 2}, effects=[mod_effect]).id) # Verification self.assertEqual(self.fit.stats.launched_drones.total, 6) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def setUp(self): CalculatorTestCase.setUp(self) self.tgt_attr = self.mkattr() src_attr = self.mkattr() modifier = self.mkmod(affectee_filter=ModAffecteeFilter.item, affectee_domain=ModDomain.character, affectee_attr_id=self.tgt_attr.id, operator=ModOperator.post_percent, affector_attr_id=src_attr.id) effect = self.mkeffect(category_id=EffectCategoryId.passive, modifiers=[modifier]) self.influence_src = Implant( self.mktype(attrs={ src_attr.id: 20 }, effects=[effect]).id) self.influence_tgt = Character( self.mktype(attrs={ self.tgt_attr.id: 100 }).id)
def test_pass_greater(self): self.fit.character = Character(self.mktype( attrs={AttrId.max_active_drones: 5}).id) item_type = self.mktype() item1 = Drone(item_type.id, state=State.online) item2 = Drone(item_type.id, state=State.online) self.fit.drones.add(item1) self.fit.drones.add(item2) # Action error1 = self.get_error(item1, Restriction.launched_drone) # Verification self.assertIsNone(error1) # Action error2 = self.get_error(item2, Restriction.launched_drone) # Verification self.assertIsNone(error2) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_other(self): # Here we check that self-reference modifies only effect item, and # nothing else is affected. We position item as character and check # another item which has character modifier domain to ensure that items # 'belonging' to self are not affected too influence_src = Character( self.mktype(attrs={ self.tgt_attr.id: 100, self.src_attr.id: 20 }, effects=[self.effect]).id) item = Implant(self.mktype(attrs={self.tgt_attr.id: 100}).id) self.fit.implants.add(item) # Action self.fit.character = influence_src # Verification self.assertAlmostEqual(item.attrs[self.tgt_attr.id], 100) # Cleanup self.assert_solsys_buffers_empty(self.fit.solar_system) self.assert_log_entries(0)
def test_fail_multiple(self): # Check that error works for multiple items self.fit.character = Character(self.mktype( attrs={AttrId.max_active_drones: 1}).id) item_type = self.mktype() item1 = Drone(item_type.id, state=State.online) item2 = Drone(item_type.id, state=State.online) self.fit.drones.add(item1) self.fit.drones.add(item2) # Action error1 = self.get_error(item1, Restriction.launched_drone) # Verification self.assertIsNotNone(error1) self.assertEqual(error1.used, 2) self.assertEqual(error1.total, 1) # Action error2 = self.get_error(item2, Restriction.launched_drone) # 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)