Ejemplo n.º 1
0
 def testFail(self):
     # Check that error is raised when number of used
     # slots exceeds slot amount provided by ship
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.slots = {Slot.moduleHigh}
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.hiSlots] = 1
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.highSlot)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.slotsMax, 1)
     self.assertEqual(restrictionError1.slotsUsed, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.highSlot)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.slotsMax, 1)
     self.assertEqual(restrictionError2.slotsUsed, 2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 2
0
 def testMixExcessOriginal(self):
     # Check that original item attributes are used
     fit = Fit()
     holder1 = ShipItem(
         self.ch.type_(typeId=1,
                       groupId=61,
                       attributes={Attribute.maxGroupFitted: 1}))
     holder1.attributes[Attribute.maxGroupFitted] = 2
     fit.items.add(holder1)
     holder2 = ShipItem(
         self.ch.type_(typeId=2,
                       groupId=61,
                       attributes={Attribute.maxGroupFitted: 2}))
     holder2.attributes[Attribute.maxGroupFitted] = 1
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.maxGroupFitted)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxGroup, 1)
     self.assertEqual(restrictionError1.holderGroup, 61)
     self.assertEqual(restrictionError1.groupHolders, 2)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.maxGroupFitted)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 3
0
 def testFailExcessAll(self):
     # Make sure error is raised for all holders exceeding
     # their group restriction
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=6, attributes={Attribute.maxGroupOnline: 1})
     holder1 = ShipItem(item)
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     holder2.state = State.online
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupOnline)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxGroup, 1)
     self.assertEqual(restrictionError1.holderGroup, 6)
     self.assertEqual(restrictionError1.groupHolders, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupOnline)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxGroup, 1)
     self.assertEqual(restrictionError2.holderGroup, 6)
     self.assertEqual(restrictionError2.groupHolders, 2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 4
0
 def testFailModified(self):
     # Make sure that modified number of slot output
     # is taken
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.slots = {Slot.moduleHigh}
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.hiSlots: 5}))
     ship.attributes[Attribute.hiSlots] = 1
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.highSlot)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.slotsMax, 1)
     self.assertEqual(restrictionError1.slotsUsed, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.highSlot)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.slotsMax, 1)
     self.assertEqual(restrictionError2.slotsUsed, 2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 5
0
 def testMixExcessOne(self):
     # Make sure error is raised for just holders which excess
     # restriction,even if they're from the same group
     fit = Fit()
     holder1 = ShipItem(
         self.ch.type_(typeId=1,
                       groupId=92,
                       attributes={Attribute.maxGroupFitted: 1}))
     fit.items.add(holder1)
     holder2 = ShipItem(
         self.ch.type_(typeId=2,
                       groupId=92,
                       attributes={Attribute.maxGroupFitted: 2}))
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.maxGroupFitted)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxGroup, 1)
     self.assertEqual(restrictionError1.holderGroup, 92)
     self.assertEqual(restrictionError1.groupHolders, 2)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.maxGroupFitted)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 6
0
 def testFailExcessAll(self):
     # Make sure error is raised for all holders exceeding
     # their group restriction
     fit = Fit()
     item = self.ch.type_(typeId=1,
                          groupId=6,
                          attributes={Attribute.maxGroupFitted: 1})
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.maxGroupFitted)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxGroup, 1)
     self.assertEqual(restrictionError1.holderGroup, 6)
     self.assertEqual(restrictionError1.groupHolders, 2)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.maxGroupFitted)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxGroup, 1)
     self.assertEqual(restrictionError2.holderGroup, 6)
     self.assertEqual(restrictionError2.groupHolders, 2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 7
0
 def testPassState(self):
     # No errors should occur if holders are not online+
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=886, attributes={Attribute.maxGroupOnline: 1})
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 8
0
 def testPassState(self):
     # No errors should occur if holders are not active+
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=886, attributes={Attribute.maxGroupActive: 1})
     holder1 = ShipItem(item)
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = ShipItem(item)
     holder2.state = State.online
     fit.items.append(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupActive)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupActive)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 9
0
 def testPassHolderNoneGroup(self):
     # Check that holders with None group are not affected
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=None, attributes={Attribute.maxGroupOnline: 1})
     holder1 = ShipItem(item)
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = ShipItem(item)
     holder2.state = State.online
     fit.items.append(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 10
0
 def testPass(self):
     # Make sure no errors are raised when number of added
     # items doesn't exceed any restrictions
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=860, attributes={Attribute.maxGroupOnline: 2})
     holder1 = ShipItem(item)
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = ShipItem(item)
     holder2.state = State.online
     fit.items.append(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 11
0
 def testPassHolderNoneGroup(self):
     # Check that holders with None group are not affected
     fit = Fit()
     item = self.ch.type_(typeId=1,
                          groupId=None,
                          attributes={Attribute.maxGroupFitted: 1})
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.maxGroupFitted)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.maxGroupFitted)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 12
0
 def testPassSubcapitalShipHolder(self):
     # Make sure no error raised when non-capital
     # item is added to fit
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 500}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.capitalItem)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 13
0
 def testMixExcessOne(self):
     # Make sure error is raised for just holders which excess
     # restriction,even if they're from the same group
     fit = Fit()
     holder1 = ShipItem(self.ch.type_(typeId=1, groupId=92, attributes={Attribute.maxGroupOnline: 1}))
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = ShipItem(self.ch.type_(typeId=2, groupId=92, attributes={Attribute.maxGroupOnline: 2}))
     holder2.state = State.online
     fit.items.append(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupOnline)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxGroup, 1)
     self.assertEqual(restrictionError1.holderGroup, 92)
     self.assertEqual(restrictionError1.groupHolders, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 14
0
 def testMixExcessOriginal(self):
     # Check that original item attributes are used
     fit = Fit()
     holder1 = ShipItem(self.ch.type_(typeId=1, groupId=61, attributes={Attribute.maxGroupOnline: 1}))
     holder1.attributes[Attribute.maxGroupOnline] = 2
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = ShipItem(self.ch.type_(typeId=2, groupId=61, attributes={Attribute.maxGroupOnline: 2}))
     holder2.attributes[Attribute.maxGroupOnline] = 1
     holder2.state = State.online
     fit.items.append(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.maxGroupOnline)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxGroup, 1)
     self.assertEqual(restrictionError1.holderGroup, 61)
     self.assertEqual(restrictionError1.groupHolders, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.maxGroupOnline)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 15
0
 def testPassNoVolume(self):
     # Check that items with no volume attribute are not restricted
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1))
     fit.items.add(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2))
     restrictionError = fit.getRestrictionError(holder, Restriction.capitalItem)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 16
0
 def testPass(self):
     # Make sure no errors are raised when number of added
     # items doesn't exceed any restrictions
     fit = Fit()
     item = self.ch.type_(typeId=1,
                          groupId=860,
                          attributes={Attribute.maxGroupFitted: 2})
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.maxGroupFitted)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.maxGroupFitted)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 17
0
 def testPassNonSlot(self):
     # If holders don't use slot, no error should
     # be raised
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.hiSlots] = 1
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.highSlot)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.highSlot)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 18
0
 def testFailNoShip(self):
     # Check that error is raised on attempt
     # to add capital item to fit w/o ship
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 501}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.capitalItem)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.allowedVolume, 500)
     self.assertEqual(restrictionError.holderVolume, 501)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 19
0
 def testPass(self):
     # No error is raised when slot users do not
     # exceed slot output
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.slots = {Slot.moduleHigh}
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.hiSlots] = 3
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.highSlot)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.highSlot)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 20
0
 def testPassCapitalShip(self):
     # Check that capital holders can be added to
     # capital ship
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 501}))
     fit.items.add(holder)
     shipItem = self.ch.type_(typeId=2)
     shipItem.requiredSkills = {ConstType.capitalShips: 1}
     fit.ship = IndependentItem(shipItem)
     restrictionError = fit.getRestrictionError(holder, Restriction.capitalItem)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 21
0
 def testFailNoShip(self):
     # Make sure that absence of ship
     # is considered as 0 output
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.slots = {Slot.moduleHigh}
     holder = ShipItem(item)
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.highSlot)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.slotsMax, 0)
     self.assertEqual(restrictionError.slotsUsed, 1)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 22
0
 def testPassGroupMatch(self):
     # When type of ship matches group-restriction attribute,
     # no error should be raised
     fit = Fit()
     ship = IndependentItem(self.ch.type_(typeId=554, groupId=23))
     fit.ship = ship
     holder = ShipItem(
         self.ch.type_(typeId=1,
                       attributes={Attribute.canFitShipGroup1: 23}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.shipTypeGroup)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 23
0
 def testFailNoShip(self):
     # Absent ship should trigger this error too
     fit = Fit()
     holder = ShipItem(
         self.ch.type_(typeId=1, attributes={Attribute.canFitShipType1:
                                             10}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.shipTypeGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedTypes, (10, ))
     self.assertCountEqual(restrictionError.allowedGroups, ())
     self.assertEqual(restrictionError.shipType, None)
     self.assertEqual(restrictionError.shipGroup, None)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 24
0
 def testFailOriginalVolume(self):
     # Make sure original volume value is taken
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 501}))
     # Set volume below 500 to check that even when
     # modified attributes are available, raw attributes
     # are taken
     holder.attributes[Attribute.volume] = 100
     fit.items.add(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2))
     restrictionError = fit.getRestrictionError(holder, Restriction.capitalItem)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.allowedVolume, 500)
     self.assertEqual(restrictionError.holderVolume, 501)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 25
0
 def testFailShipNoAttr(self):
     # Make sure that absence of specifier of slot output
     # is considered as 0 output
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.slots = {Slot.moduleHigh}
     holder = ShipItem(item)
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.highSlot)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.slotsMax, 0)
     self.assertEqual(restrictionError.slotsUsed, 1)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 26
0
 def testFailType5(self):
     # Check that fifth type-restriction attribute affects
     # holder
     fit = Fit()
     ship = IndependentItem(self.ch.type_(typeId=772, groupId=31))
     fit.ship = ship
     holder = ShipItem(
         self.ch.type_(typeId=1, attributes={Attribute.fitsToShipType: 10}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.shipTypeGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedTypes, (10, ))
     self.assertCountEqual(restrictionError.allowedGroups, ())
     self.assertEqual(restrictionError.shipType, 772)
     self.assertEqual(restrictionError.shipGroup, 31)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 27
0
 def testPassCombinedMatch(self):
     # Check that it's enough to match any condition
     # to be fittable
     fit = Fit()
     ship = IndependentItem(self.ch.type_(typeId=554, groupId=23))
     fit.ship = ship
     holder = ShipItem(
         self.ch.type_(typeId=1,
                       attributes={
                           Attribute.canFitShipType1: 1089,
                           Attribute.canFitShipGroup1: 23
                       }))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.shipTypeGroup)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 28
0
 def testFailAttrOriginal(self):
     # Make sure original value is taken
     fit = Fit()
     ship = IndependentItem(self.ch.type_(typeId=772, groupId=31))
     fit.ship = ship
     holder = ShipItem(
         self.ch.type_(typeId=1, attributes={Attribute.canFitShipType1:
                                             10}))
     holder.attributes[Attribute.canFitShipType1] = 772
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.shipTypeGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedTypes, (10, ))
     self.assertCountEqual(restrictionError.allowedGroups, ())
     self.assertEqual(restrictionError.shipType, 772)
     self.assertEqual(restrictionError.shipGroup, 31)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 29
0
 def testFailCombined(self):
     # Check that failure is appropriately generated when
     # holder specifies both type and group restrictions
     fit = Fit()
     ship = IndependentItem(self.ch.type_(typeId=772, groupId=31))
     fit.ship = ship
     holder = ShipItem(
         self.ch.type_(typeId=1,
                       attributes={
                           Attribute.canFitShipType1: 1089,
                           Attribute.canFitShipGroup1: 23
                       }))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.shipTypeGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedTypes, (1089, ))
     self.assertCountEqual(restrictionError.allowedGroups, (23, ))
     self.assertEqual(restrictionError.shipType, 772)
     self.assertEqual(restrictionError.shipGroup, 31)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)