Esempio n. 1
0
 def test_fail_original(self):
     # Make sure that original attributes are used
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.subsystem_slot: 120})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Subsystem(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Subsystem(1))
     holder1.attributes = {Attribute.subsystem_slot: 119}
     holder2.attributes = {Attribute.subsystem_slot: 121}
     self.track_holder(holder1)
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.subsystem_index)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.holder_slot_index, 120)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.subsystem_index)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.holder_slot_index, 120)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 2
0
 def test_pass_different(self):
     # Holders taking different slots shouldn't trigger any errors
     item1 = self.ch.type_(type_id=1,
                           attributes={Attribute.subsystem_slot: 120})
     item2 = self.ch.type_(type_id=2,
                           attributes={Attribute.subsystem_slot: 121})
     holder1 = Mock(state=State.offline,
                    item=item1,
                    _domain=Domain.ship,
                    spec_set=Subsystem(1))
     holder2 = Mock(state=State.offline,
                    item=item2,
                    _domain=Domain.ship,
                    spec_set=Subsystem(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.subsystem_index)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.subsystem_index)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 3
0
 def test_fail(self):
     # Check that if 2 or more holders are put into single slot
     # index, error is raised
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.subsystem_slot: 120})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Subsystem(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Subsystem(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.subsystem_index)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.holder_slot_index, 120)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.subsystem_index)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.holder_slot_index, 120)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 4
0
 def test_pass_greater(self):
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     self.fit.subsystems.add(holder1)
     self.fit.subsystems.add(holder2)
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.fit.stats.subsystem_slots.used = 2
     self.fit.stats.subsystem_slots.total = 5
     restriction_error1 = self.get_restriction_error(holder1, Restriction.subsystem_slot)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.subsystem_slot)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 5
0
 def test_pass(self):
     # Single holder which takes some slot shouldn't
     # trigger any errors
     item = self.ch.type_(type_id=1, attributes={Attribute.subsystem_slot: 120})
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     self.track_holder(holder)
     restriction_error = self.get_restriction_error(holder, Restriction.subsystem_index)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 6
0
 def test_pass_other_container(self):
     item = self.ch.type_(type_id=1)
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     self.fit.rigs.add(holder)
     self.track_holder(holder)
     self.fit.stats.subsystem_slots.used = 1
     self.fit.stats.subsystem_slots.total = 0
     restriction_error = self.get_restriction_error(holder, Restriction.subsystem_slot)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 7
0
 def test_fail_excess_multiple(self):
     # Check that error works for multiple holders
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     self.fit.subsystems.add(holder1)
     self.fit.subsystems.add(holder2)
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.fit.stats.subsystem_slots.used = 2
     self.fit.stats.subsystem_slots.total = 1
     restriction_error1 = self.get_restriction_error(holder1, Restriction.subsystem_slot)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.slots_max_allowed, 1)
     self.assertEqual(restriction_error1.slots_used, 2)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.subsystem_slot)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.slots_max_allowed, 1)
     self.assertEqual(restriction_error2.slots_used, 2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 8
0
 def test_fail_excess_signle_undefined_output(self):
     # When stats module does not specify total slot amount,
     # make sure it's assumed to be 0
     item = self.ch.type_(type_id=1)
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     self.fit.subsystems.add(holder)
     self.track_holder(holder)
     self.fit.stats.subsystem_slots.used = 1
     self.fit.stats.subsystem_slots.total = None
     restriction_error = self.get_restriction_error(holder, Restriction.subsystem_slot)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.slots_max_allowed, 0)
     self.assertEqual(restriction_error.slots_used, 1)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
Esempio n. 9
0
 def test_fail_excess_signle(self):
     # Check that error is raised when number of used
     # slots exceeds slot amount provided by ship
     item = self.ch.type_(type_id=1)
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Subsystem(1))
     self.fit.subsystems.add(holder)
     self.track_holder(holder)
     self.fit.stats.subsystem_slots.used = 1
     self.fit.stats.subsystem_slots.total = 0
     restriction_error = self.get_restriction_error(holder, Restriction.subsystem_slot)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.slots_max_allowed, 0)
     self.assertEqual(restriction_error.slots_used, 1)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()