Ejemplo n.º 1
0
 def testMixUsageZero(self):
     # If some holder has zero usage and cpu error is
     # still raised, check it's not raised for holder with
     # zero usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.cpu: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.cpu] = 100
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.cpu] = 0
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.cpuOutput] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.cpu)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 100)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.cpu)
     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.º 2
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.º 3
0
 def testPassNegativeUse(self):
     # Check that even if use of one holder exceeds
     # cpu output, negative use of other holder may help
     # to avoid raising error
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.cpu: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.cpu] = 50
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.cpu] = -15
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.cpuOutput] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.cpu)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.cpu)
     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.º 4
0
 def testPass(self):
     # When total consumption is less than output,
     # no errors should be raised
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.cpu: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.cpu] = 25
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.cpu] = 20
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.cpuOutput] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.cpu)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.cpu)
     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.º 5
0
 def testMixUsageZero(self):
     # If some holder has zero usage and drone bay volume error is
     # still raised, check it's not raised for holder with
     # zero usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.volume: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.volume] = 100
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.volume] = 0
     fit.drones.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneCapacity] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.droneBayVolume)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 100)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.droneBayVolume)
     self.assertIsNone(restrictionError2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 6
0
 def testPassNegativeUse(self):
     # Check that even if use of one holder exceeds drone bay volume
     # output, negative use of other holder may help to avoid raising error
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.volume: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.volume] = 50
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.volume] = -15
     fit.drones.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneCapacity] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.droneBayVolume)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.droneBayVolume)
     self.assertIsNone(restrictionError2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 7
0
 def testMixUsageZero(self):
     # If some holder has zero usage and calibration error is
     # still raised, check it's not raised for holder with
     # zero usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.upgradeCost: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.upgradeCost] = 100
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.upgradeCost] = 0
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.upgradeCapacity] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.calibration)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 100)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.calibration)
     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.º 8
0
 def testPassNegativeUse(self):
     # Check that even if use of one holder exceeds
     # drone bandwidth output, negative use of other holder may help
     # to avoid raising error
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.droneBandwidthUsed: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.droneBandwidthUsed] = 50
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.droneBandwidthUsed] = -15
     holder2.state = State.online
     fit.items.append(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneBandwidth] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.droneBandwidth)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.droneBandwidth)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 9
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.subsystem}
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.maxSubSystems: 5}))
     ship.attributes[Attribute.maxSubSystems] = 1
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.subsystemSlot)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.slotsMax, 1)
     self.assertEqual(restrictionError1.slotsUsed, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.subsystemSlot)
     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.assertBuffersEmpty(fit)
Ejemplo n.º 10
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.subsystem}
     holder1 = ShipItem(item)
     fit.items.add(holder1)
     holder2 = ShipItem(item)
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.maxSubSystems] = 1
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.subsystemSlot)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.slotsMax, 1)
     self.assertEqual(restrictionError1.slotsUsed, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.subsystemSlot)
     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.assertBuffersEmpty(fit)
Ejemplo n.º 11
0
 def testMixUsageZero(self):
     # If some holder has zero usage and power grid error is
     # still raised, check it's not raised for holder with
     # zero usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.power: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.power] = 100
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.power] = 0
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.powerOutput] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.powerGrid)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 100)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.powerGrid)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 12
0
 def testPass(self):
     # When total consumption is less than output,
     # no errors should be raised
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.power: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.power] = 25
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.power] = 20
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.powerOutput] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.powerGrid)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.powerGrid)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 13
0
 def testPassNegativeUse(self):
     # Check that even if use of one holder exceeds
     # power grid output, negative use of other holder may help
     # to avoid raising error
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.power: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.power] = 50
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.power] = -15
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.powerOutput] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.powerGrid)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.powerGrid)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 14
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.º 15
0
 def testFailExcessMultiple(self):
     # When multiple consumers require less than drone bay volume output
     # alone, but in sum want more than total output, it should
     # be erroneous situation
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.volume: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.volume] = 25
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.volume] = 20
     fit.drones.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneCapacity] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.droneBayVolume)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 40)
     self.assertEqual(restrictionError1.totalUsage, 45)
     self.assertEqual(restrictionError1.holderConsumption, 25)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.droneBayVolume)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.output, 40)
     self.assertEqual(restrictionError2.totalUsage, 45)
     self.assertEqual(restrictionError2.holderConsumption, 20)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 16
0
 def testMixUsageNegative(self):
     # If some holder has negative usage and drone bandwidth error is
     # still raised, check it's not raised for holder with
     # negative usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.droneBandwidthUsed: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.droneBandwidthUsed] = 100
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.droneBandwidthUsed] = -10
     holder2.state = State.online
     fit.items.append(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneBandwidth] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.droneBandwidth)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 90)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.droneBandwidth)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 17
0
 def testMixUsageNegative(self):
     # If some holder has negative usage and drone bay volume error is
     # still raised, check it's not raised for holder with
     # negative usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.volume: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.volume] = 100
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.volume] = -10
     fit.drones.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneCapacity] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.droneBayVolume)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 90)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.droneBayVolume)
     self.assertIsNone(restrictionError2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 18
0
 def testMixUsageNegative(self):
     # If some holder has negative usage and calibration error is
     # still raised, check it's not raised for holder with
     # negative usage
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.upgradeCost: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.upgradeCost] = 100
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.upgradeCost] = -10
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.upgradeCapacity] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.calibration)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 50)
     self.assertEqual(restrictionError1.totalUsage, 90)
     self.assertEqual(restrictionError1.holderConsumption, 100)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.calibration)
     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.º 19
0
 def testFailExcessMultiple(self):
     # When multiple consumers require less than cpu output
     # alone, but in sum want more than total output, it should
     # be erroneous situation
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.cpu: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.cpu] = 25
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.cpu] = 20
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.cpuOutput] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.cpu)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 40)
     self.assertEqual(restrictionError1.totalUsage, 45)
     self.assertEqual(restrictionError1.holderConsumption, 25)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.cpu)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.output, 40)
     self.assertEqual(restrictionError2.totalUsage, 45)
     self.assertEqual(restrictionError2.holderConsumption, 20)
     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 testPass(self):
     # When total consumption is less than output,
     # no errors should be raised
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.volume: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.volume] = 25
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.volume] = 20
     fit.drones.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneCapacity] = 50
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.droneBayVolume)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.droneBayVolume)
     self.assertIsNone(restrictionError2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 21
0
 def testFailExcessMultiple(self):
     # When multiple consumers require less than power grid output
     # alone, but in sum want more than total output, it should
     # be erroneous situation
     fit = Fit()
     item = self.ch.type_(typeId=1, attributes={Attribute.power: 0})
     holder1 = IndependentItem(item)
     holder1.attributes[Attribute.power] = 25
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.power] = 20
     holder2.state = State.online
     fit.items.add(holder2)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.powerOutput] = 40
     fit.ship = ship
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.powerGrid)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.output, 40)
     self.assertEqual(restrictionError1.totalUsage, 45)
     self.assertEqual(restrictionError1.holderConsumption, 25)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.powerGrid)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.output, 40)
     self.assertEqual(restrictionError2.totalUsage, 45)
     self.assertEqual(restrictionError2.holderConsumption, 20)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 22
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 23
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 24
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.º 25
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 26
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.append(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.shipTypeGroup)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(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.append(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.shipTypeGroup)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 28
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.append(holder)
     restrictionError = fit.getRestrictionError(holder, Restriction.shipTypeGroup)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 29
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 30
0
 def testPassMatch1(self):
     # Check that no error raised when drone of group
     # matching to first restriction attribute is added
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=22))
     fit.drones.add(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.allowedDroneGroup1: 22}))
     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)
Ejemplo n.º 31
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 32
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 33
0
 def testFailDroneNone(self):
     # Check that drone from None group is subject
     # to restriction
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=None))
     fit.drones.append(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.allowedDroneGroup1: 1896}))
     restrictionError = fit.getRestrictionError(holder, Restriction.droneGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedGroups, (1896,))
     self.assertEqual(restrictionError.droneGroup, None)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 34
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 35
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.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 36
0
 def testFailMismatch2(self):
     # Check that error is returned on attempt
     # to add drone from group mismatching to
     # second restriction attribute
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=797))
     fit.drones.append(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.allowedDroneGroup2: 69}))
     restrictionError = fit.getRestrictionError(holder, Restriction.droneGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedGroups, (69,))
     self.assertEqual(restrictionError.droneGroup, 797)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 37
0
 def testFailMismatchCombined(self):
     # Check that error is returned on attempt
     # to add drone from group mismatching to
     # both restriction attributes
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=803))
     fit.drones.append(holder)
     fit.ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.allowedDroneGroup1: 48, Attribute.allowedDroneGroup2: 106}))
     restrictionError = fit.getRestrictionError(holder, Restriction.droneGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedGroups, (48, 106))
     self.assertEqual(restrictionError.droneGroup, 803)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 38
0
 def testFailSubcapitalShip(self):
     # Check that error is raised on attempt
     # to add capital item to fit with subcapital
     # ship
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 501}))
     fit.items.append(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.assertBuffersEmpty(fit)
Ejemplo n.º 39
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)
Ejemplo n.º 40
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)
Ejemplo n.º 41
0
 def testFailMismatch(self):
     # Error should be raised when mismatching rig size
     # is added to ship
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.rigSize: 10}))
     fit.items.append(holder)
     ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.rigSize: 6}))
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.rigSize)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.allowedSize, 6)
     self.assertEqual(restrictionError.holderSize, 10)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 42
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)
Ejemplo n.º 43
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.power: 0}))
     holder.attributes[Attribute.power] = 50
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.powerOutput] = 40
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.powerGrid)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Ejemplo n.º 44
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.º 45
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)
Ejemplo n.º 46
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.upgradeCost] = 100
     fit.items.append(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.upgradeCapacity] = 50
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.calibration)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Ejemplo n.º 47
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)
Ejemplo n.º 48
0
 def testFailSubcapitalShip(self):
     # Check that error is raised on attempt
     # to add capital item to fit with subcapital
     # ship
     fit = Fit()
     holder = ShipItem(self.ch.type_(typeId=1, attributes={Attribute.volume: 501}))
     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.º 49
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)
Ejemplo n.º 50
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.º 51
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)
Ejemplo n.º 52
0
 def testFailMismatch(self):
     # Error should be raised when mismatching rig size
     # is added to ship
     fit = Fit()
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.rigSize: 10}))
     fit.items.add(holder)
     ship = IndependentItem(
         self.ch.type_(typeId=2, attributes={Attribute.rigSize: 6}))
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.rigSize)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.allowedSize, 6)
     self.assertEqual(restrictionError.holderSize, 10)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 53
0
 def testFailDroneNone(self):
     # Check that drone from None group is subject
     # to restriction
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=None))
     fit.drones.add(holder)
     fit.ship = IndependentItem(
         self.ch.type_(typeId=2,
                       attributes={Attribute.allowedDroneGroup1: 1896}))
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedGroups, (1896, ))
     self.assertEqual(restrictionError.droneGroup, None)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 54
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.º 55
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.º 56
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)
Ejemplo n.º 57
0
 def testFailOriginal(self):
     # Original value must be taken
     fit = Fit()
     holder = IndependentItem(
         self.ch.type_(typeId=1, attributes={Attribute.rigSize: 10}))
     holder.attributes[Attribute.rigSize] = 5
     fit.items.add(holder)
     ship = IndependentItem(
         self.ch.type_(typeId=2, attributes={Attribute.rigSize: 6}))
     ship.attributes[Attribute.rigSize] = 5
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.rigSize)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.allowedSize, 6)
     self.assertEqual(restrictionError.holderSize, 10)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 58
0
 def testFailMismatch2(self):
     # Check that error is returned on attempt
     # to add drone from group mismatching to
     # second restriction attribute
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, groupId=797))
     fit.drones.add(holder)
     fit.ship = IndependentItem(
         self.ch.type_(typeId=2,
                       attributes={Attribute.allowedDroneGroup2: 69}))
     restrictionError = fit.getRestrictionError(holder,
                                                Restriction.droneGroup)
     self.assertIsNotNone(restrictionError)
     self.assertCountEqual(restrictionError.allowedGroups, (69, ))
     self.assertEqual(restrictionError.droneGroup, 797)
     fit.drones.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 59
0
 def testFailExcessModified(self):
     # Make sure modified drone bandwidth values are taken
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.droneBandwidthUsed: 40}))
     holder.attributes[Attribute.droneBandwidthUsed] = 100
     holder.state = State.online
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.droneBandwidth: 45}))
     ship.attributes[Attribute.droneBandwidth] = 50
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.droneBandwidth)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.output, 50)
     self.assertEqual(restrictionError.totalUsage, 100)
     self.assertEqual(restrictionError.holderConsumption, 100)
     fit.items.remove(holder)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Ejemplo n.º 60
0
 def testFailExcessShipNoAttr(self):
     # When ship is assigned, but doesn't have drone bandwidth output
     # attribute, error should be raised for drone bandwidth consumers too
     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)
     ship = IndependentItem(self.ch.type_(typeId=2))
     fit.ship = ship
     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)
     fit.ship = None
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)