Exemplo n.º 1
0
 def test_use_multiple(self):
     self.fit.subsystems.add(Subsystem(self.mktype().id))
     self.fit.subsystems.add(Subsystem(self.mktype().id))
     # Verification
     self.assertEqual(self.fit.stats.subsystem_slots.used, 2)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 2
0
 def test_pass_items_not_loaded(self):
     item_type_id = self.allocate_type_id()
     item1 = Subsystem(item_type_id)
     item2 = Subsystem(item_type_id)
     self.fit.subsystems.add(item1)
     self.fit.subsystems.add(item2)
     # Action
     error1 = self.get_error(item1, Restriction.subsystem_index)
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.subsystem_index)
     self.assertIsNone(error2)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 3
0
 def test_use_item_not_loaded(self):
     self.fit.subsystems.add(Subsystem(self.allocate_type_id()))
     # Verification
     self.assertEqual(self.fit.stats.subsystem_slots.used, 1)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 4
0
 def test_pass_slots_different(self):
     # Items taking different slots shouldn't trigger any errors
     item1 = Subsystem(self.mktype(attrs={self.index_attr.id: 120}).id)
     item2 = Subsystem(self.mktype(attrs={self.index_attr.id: 121}).id)
     self.fit.subsystems.add(item1)
     self.fit.subsystems.add(item2)
     # Action
     error1 = self.get_error(item1, Restriction.subsystem_index)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.subsystem_index)
     # Verification
     self.assertIsNone(error2)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 5
0
 def test_pass_greater(self):
     self.fit.ship = Ship(self.mktype(attrs={AttrId.max_subsystems: 5}).id)
     item_type = self.mktype()
     item1 = Subsystem(item_type.id)
     item2 = Subsystem(item_type.id)
     self.fit.subsystems.add(item1)
     self.fit.subsystems.add(item2)
     # Action
     error1 = self.get_error(item1, Restriction.subsystem_slot)
     # Verification
     self.assertIsNone(error1)
     # Action
     error2 = self.get_error(item2, Restriction.subsystem_slot)
     # Verification
     self.assertIsNone(error2)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 6
0
 def test_fail(self):
     # Check that if 2 or more items are put into single slot index, error is
     # raised
     item_type = self.mktype(attrs={self.index_attr.id: 120})
     item1 = Subsystem(item_type.id)
     item2 = Subsystem(item_type.id)
     self.fit.subsystems.add(item1)
     self.fit.subsystems.add(item2)
     # Action
     error1 = self.get_error(item1, Restriction.subsystem_index)
     self.assertIsNotNone(error1)
     self.assertEqual(error1.slot_index, 120)
     # Action
     error2 = self.get_error(item2, Restriction.subsystem_index)
     self.assertIsNotNone(error2)
     self.assertEqual(error2.slot_index, 120)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 7
0
 def test_subsystem_fail_not_loaded(self):
     item = Subsystem(self.allocate_type_id())
     self.fit.subsystems.add(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)
Exemplo n.º 8
0
 def test_subsystem_pass_loaded(self):
     item = Subsystem(self.mktype().id)
     self.fit.subsystems.add(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)
Exemplo n.º 9
0
 def test_subsystem(self):
     subsystem = Subsystem(self.make_item_types())
     self.fit.subsystems.add(subsystem)
     self.assertAlmostEqual(subsystem.attrs[self.tgt_attr_id], 18)
     # Action
     self.fit.solar_system.source = 'src2'
     # Verification
     self.assertAlmostEqual(subsystem.attrs[self.tgt_attr_id], 14)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 10
0
 def test_pass(self):
     # Single item which takes some slot shouldn't trigger any errors
     item = Subsystem(self.mktype(attrs={self.index_attr.id: 120}).id)
     self.fit.subsystems.add(item)
     # Action
     error = self.get_error(item, Restriction.subsystem_index)
     # Verification
     self.assertIsNone(error)
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 11
0
 def test_fail_ship_not_loaded(self):
     self.fit.ship = Ship(self.allocate_type_id())
     item = Subsystem(self.mktype().id)
     self.fit.subsystems.add(item)
     # Action
     error = self.get_error(item, Restriction.subsystem_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)
Exemplo n.º 12
0
 def test_subsystem_pass(self):
     effect = self.mkeffect(effect_id=EffectId.subsystem,
                            category_id=EffectCategoryId.passive)
     item = Subsystem(
         self.mktype(category_id=TypeCategoryId.subsystem,
                     effects=[effect]).id)
     self.fit.subsystems.add(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)
Exemplo n.º 13
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 = Subsystem(self.mktype().id)
     self.fit.subsystems.add(item)
     # Action
     error = self.get_error(item, Restriction.subsystem_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)
Exemplo n.º 14
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.max_subsystems: 0}).id)
     item = Subsystem(self.allocate_type_id())
     self.fit.subsystems.add(item)
     # Action
     error = self.get_error(item, Restriction.subsystem_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)
Exemplo n.º 15
0
 def test_fail_multiple(self):
     # Check that error works for multiple items
     self.fit.ship = Ship(self.mktype(attrs={AttrId.max_subsystems: 1}).id)
     item_type = self.mktype()
     item1 = Subsystem(item_type.id)
     item2 = Subsystem(item_type.id)
     self.fit.subsystems.add(item1)
     self.fit.subsystems.add(item2)
     # Action
     error1 = self.get_error(item1, Restriction.subsystem_slot)
     # Verification
     self.assertIsNotNone(error1)
     self.assertEqual(error1.used, 2)
     self.assertEqual(error1.total, 1)
     # Action
     error2 = self.get_error(item2, Restriction.subsystem_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)
Exemplo n.º 16
0
 def test_subsystem_fail_category_other(self):
     effect = self.mkeffect(effect_id=EffectId.subsystem,
                            category_id=EffectCategoryId.passive)
     item = Subsystem(self.mktype(category_id=1008, effects=[effect]).id)
     self.fit.subsystems.add(item)
     # Action
     error = self.get_error(item, Restriction.item_class)
     # Verification
     self.assertIsNotNone(error)
     self.assertEqual(error.item_class, Subsystem)
     self.assertCountEqual(error.allowed_classes, [])
     # Cleanup
     self.assert_solsys_buffers_empty(self.fit.solar_system)
     self.assert_log_entries(0)
Exemplo n.º 17
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.max_subsystems: 0}).id)
     item = Subsystem(self.mktype().id)
     self.fit.subsystems.add(item)
     # Action
     error = self.get_error(item, Restriction.subsystem_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)