Пример #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.launcher}
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.launcherSlotsLeft] = 1
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.launcherSlot)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.slotsMax, 1)
     self.assertEqual(restrictionError1.slotsUsed, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.launcherSlot)
     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)
Пример #2
0
 def testPass(self):
     # No error should be raised when single skill
     # is added to fit
     fit = Fit()
     skill = Skill(self.ch.type_(typeId=56))
     fit.items.add(skill)
     restrictionError = fit.getRestrictionError(skill, Restriction.skillUniqueness)
     self.assertIsNone(restrictionError)
     fit.items.remove(skill)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #3
0
 def testPassNonShipHolder(self):
     # Check that non-ship holders are not affected
     # by restriction
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 501}))
     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)
Пример #4
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)
Пример #5
0
 def testPassNoShip(self):
     # Check that restriction isn't applied
     # when fit doesn't have ship
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=None))
     fit.drones.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneGroup)
     self.assertIsNone(restrictionError)
     fit.drones.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #6
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)
Пример #7
0
 def testPassNoShip(self):
     # When no ship is assigned, no restriction
     # should be applied to ships
     fit = Fit()
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.rigSize: 10}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.rigSize)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #8
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)
Пример #9
0
 def testPass(self):
     # Single holder which takes some slot shouldn't
     # trigger any errors
     fit = Fit()
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.boosterness: 120}))
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.boosterIndex)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #10
0
 def testFailMultiple(self):
     # Check error raised when multiple skill requirements
     # are not met
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.requiredSkills = {48: 1, 50: 5}
     holder = IndependentItem(item)
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError, ((50, None, 5), (48, None, 1)))
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #11
0
 def testFailSingle(self):
     # Check that error is raised when single skill requirement
     # is not met
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.requiredSkills = {50: 3}
     holder = IndependentItem(item)
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError, ((50, None, 3),))
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #12
0
 def testPassState(self):
     # When holder isn't online, it shouldn't consume anything
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.droneBandwidthUsed: 0}))
     holder.attributes[Attribute.droneBandwidthUsed] = 50
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneBandwidth] = 40
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.droneBandwidth)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #13
0
 def testPassShipNoRestriction(self):
     # Check that restriction isn't applied
     # when fit has ship, but without restriction
     # attribute
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=71))
     fit.drones.add(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2))
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneGroup)
     self.assertIsNone(restrictionError)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #14
0
 def testFailExcessNoShip(self):
     # Make sure error is raised on fits without ship
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.droneBandwidthUsed: 0}))
     holder.attributes[Attribute.droneBandwidthUsed] = 50
     holder.state = State.online
     fit.items.add(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.droneBandwidth)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.output, 0)
     self.assertEqual(restrictionError.totalUsage, 50)
     self.assertEqual(restrictionError.holderConsumption, 50)
     fit.items.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #15
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)
Пример #16
0
 def testPassShipNoAttr(self):
     # If ship doesn't have rig size attribute,
     # no restriction is applied onto rigs
     fit = Fit()
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.rigSize: 10}))
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.rigSize)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #17
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)
Пример #18
0
 def testPassNone(self):
     # When typeIDs of skills are None, they should be ignored
     fit = Fit()
     item = self.ch.type_(typeId=None)
     skill1 = Skill(item)
     fit.items.add(skill1)
     skill2 = Skill(item)
     fit.items.add(skill2)
     restrictionError1 = fit.getRestrictionError(skill1, Restriction.skillUniqueness)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(skill2, Restriction.skillUniqueness)
     self.assertIsNone(restrictionError2)
     fit.items.remove(skill1)
     fit.items.remove(skill2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #19
0
 def testFailExcessNoChar(self):
     # Check that any positive number of drones
     # results in error when no character is assigned
     # to fit
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1))
     holder.state = State.online
     fit.drones.add(holder)
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.maxLaunchedDrones, 0)
     self.assertEqual(restrictionError.launchedDrones, 1)
     fit.drones.remove(holder)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #20
0
 def testPassNonDrone(self):
     # Check that restriction is not applied
     # to holders which are not drones
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=56))
     fit.items.add(holder)
     fit.ship = IndependentItem(
         self.ch.type_(typeId=2,
                       attributes={Attribute.allowedDroneGroup1: 4}))
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneGroup)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #21
0
 def testPassNonSkills(self):
     # Not-skill holders shouldn't be tracked
     fit = Fit()
     item = self.ch.type_(typeId=70)
     holder1 = IndependentItem(item)
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     fit.items.add(holder2)
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.skillUniqueness)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.skillUniqueness)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #22
0
 def testPassMatch2(self):
     # Check that no error raised when drone of group
     # matching to second restriction attribute is added
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=67))
     fit.drones.add(holder)
     fit.ship = IndependentItem(
         self.ch.type_(typeId=2,
                       attributes={Attribute.allowedDroneGroup2: 67}))
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneGroup)
     self.assertIsNone(restrictionError)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #23
0
 def testPassNonShipHolder(self):
     # Holders not belonging to ship shouldn't be affected
     fit = Fit()
     ship = IndependentItem(self.ch.type_(typeId=772, groupId=31))
     fit.ship = ship
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.canFitShipType1:
                                             10}))
     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)
Пример #24
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)
Пример #25
0
 def testPassSatisfied(self):
     # Check that error isn't raised when all skill requirements
     # are met
     fit = Fit()
     item = self.ch.type_(typeId=1)
     item.requiredSkills = {50: 3}
     holder = IndependentItem(item)
     fit.items.add(holder)
     skill = Skill(self.ch.type_(typeId=50))
     skill.level = 3
     fit.items.add(skill)
     restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.items.remove(skill)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #26
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)
Пример #27
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)
Пример #28
0
 def testPassNonDrone(self):
     # Make sure nothing but drone container is restricted
     fit = Fit()
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.volume: 0}))
     holder.attributes[Attribute.volume] = 50
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneCapacity] = 40
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneBayVolume)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #29
0
 def testPassNoOriginalAttr(self):
     # When added holder's item doesn't have original attribute,
     # holder shouldn't be tracked by register, and thus, no
     # errors should be raised
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1))
     holder.attributes[Attribute.cpu] = 100
     holder.state = State.online
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.cpuOutput] = 50
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.cpu)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Пример #30
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)