Beispiel #1
0
 def testFailExcess(self):
     # Check that excessive number of drones results
     # in failure, even when character is assigned to
     # fit and max number attribute is available
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.drones.add(holder2)
     char = IndependentItem(self.ch.type_(typeId=2))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError1.launchedDrones, 2)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError2.launchedDrones, 2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
0
 def testFailExcessModified(self):
     # Check that modified attribute value is taken, not original
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.drones.add(holder2)
     char = IndependentItem(
         self.ch.type_(typeId=2, attributes={Attribute.maxActiveDrones: 3}))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError1.launchedDrones, 2)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError2.launchedDrones, 2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Beispiel #7
0
 def testFailExcess(self):
     # Check that excessive number of drones results
     # in failure, even when character is assigned to
     # fit and max number attribute is available
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.drones.add(holder2)
     char = IndependentItem(self.ch.type_(typeId=2))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError1.launchedDrones, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError2.launchedDrones, 2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Beispiel #8
0
 def testFailNoAttr(self):
     # Check that any positive number of drones
     # results in error when character is assigned
     # to fit, but no restriction attribute available
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.drones.add(holder2)
     char = IndependentItem(self.ch.type_(typeId=2))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError1.launchedDrones, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError2.launchedDrones, 2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Beispiel #9
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.add(holder1)
     holder2 = IndependentItem(item)
     holder2.attributes[Attribute.droneBandwidthUsed] = -10
     holder2.state = State.online
     fit.items.add(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.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
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)
Beispiel #13
0
 def testFailExcessModified(self):
     # Check that modified attribute value is taken, not original
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.drones.add(holder2)
     char = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.maxActiveDrones: 3}))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError1)
     self.assertEqual(restrictionError1.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError1.launchedDrones, 2)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.launchedDrone)
     self.assertIsNotNone(restrictionError2)
     self.assertEqual(restrictionError2.maxLaunchedDrones, 1)
     self.assertEqual(restrictionError2.launchedDrones, 2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertBuffersEmpty(fit)
Beispiel #14
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)
Beispiel #15
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)
Beispiel #16
0
 def testPassHolderNonShip(self):
     # Non-ship holders shouldn't be affected
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=12, attributes={Attribute.maxGroupActive: 1})
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = IndependentItem(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)
Beispiel #17
0
 def testPassHolderNonShip(self):
     # Non-ship holders shouldn't be affected
     fit = Fit()
     item = self.ch.type_(typeId=1, groupId=12, attributes={Attribute.maxGroupActive: 1})
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.items.add(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.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Beispiel #18
0
 def testPassNonDrone(self):
     # Check excessive number of non-drone items
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.items.append(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.items.append(holder2)
     char = IndependentItem(self.ch.type_(typeId=2))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.launchedDrone)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.launchedDrone)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertBuffersEmpty(fit)
Beispiel #19
0
 def testPass(self):
     # Check non-excessive number of drones
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.drones.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.drones.add(holder2)
     char = IndependentItem(self.ch.type_(typeId=2))
     char.attributes[Attribute.maxActiveDrones] = 5
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1, Restriction.launchedDrone)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2, Restriction.launchedDrone)
     self.assertIsNone(restrictionError2)
     fit.drones.remove(holder1)
     fit.drones.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Beispiel #20
0
 def testPassNonDrone(self):
     # Check excessive number of non-drone items
     fit = Fit()
     item = self.ch.type_(typeId=1)
     holder1 = IndependentItem(item)
     holder1.state = State.online
     fit.items.add(holder1)
     holder2 = IndependentItem(item)
     holder2.state = State.online
     fit.items.add(holder2)
     char = IndependentItem(self.ch.type_(typeId=2))
     char.attributes[Attribute.maxActiveDrones] = 1
     fit.character = char
     restrictionError1 = fit.getRestrictionError(holder1,
                                                 Restriction.launchedDrone)
     self.assertIsNone(restrictionError1)
     restrictionError2 = fit.getRestrictionError(holder2,
                                                 Restriction.launchedDrone)
     self.assertIsNone(restrictionError2)
     fit.items.remove(holder1)
     fit.items.remove(holder2)
     self.assertEqual(len(self.log), 0)
     self.assertRestrictionBuffersEmpty(fit)
Beispiel #21
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.append(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.assertBuffersEmpty(fit)
Beispiel #22
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.append(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.assertBuffersEmpty(fit)
Beispiel #23
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)
Beispiel #24
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)
Beispiel #25
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.droneBandwidthUsed] = 100
     holder.state = State.online
     fit.items.append(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     ship.attributes[Attribute.droneBandwidth] = 50
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.droneBandwidth)
     self.assertIsNone(restrictionError)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Beispiel #26
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.append(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.assertBuffersEmpty(fit)
Beispiel #27
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)
Beispiel #28
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.append(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.assertBuffersEmpty(fit)
Beispiel #29
0
 def testFailExcessShipNoAttr(self):
     # When ship is assigned, but doesn't have power grid output
     # attribute, error should be raised for power grid consumers too
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.power: 0}))
     holder.attributes[Attribute.power] = 50
     holder.state = State.online
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2))
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.powerGrid)
     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)
Beispiel #30
0
 def testFailExcessModified(self):
     # Make sure modified power grid values are taken
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.power: 40}))
     holder.attributes[Attribute.power] = 100
     holder.state = State.online
     fit.items.add(holder)
     ship = IndependentItem(self.ch.type_(typeId=2, attributes={Attribute.powerOutput: 45}))
     ship.attributes[Attribute.powerOutput] = 50
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.powerGrid)
     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.assertBuffersEmpty(fit)
Beispiel #31
0
 def testFailExcessSingle(self):
     # When ship provides drone bandwidth output, but single consumer
     # demands for more, error should be raised
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, attributes={Attribute.droneBandwidthUsed: 0}))
     holder.attributes[Attribute.droneBandwidthUsed] = 50
     holder.state = State.online
     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.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.output, 40)
     self.assertEqual(restrictionError.totalUsage, 50)
     self.assertEqual(restrictionError.holderConsumption, 50)
     fit.items.remove(holder)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Beispiel #32
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)
Beispiel #33
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)
Beispiel #34
0
 def testFailExcessSingle(self):
     # When ship provides drone bandwidth output, but single consumer
     # demands for more, error should be raised
     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))
     ship.attributes[Attribute.droneBandwidth] = 40
     fit.ship = ship
     restrictionError = fit.getRestrictionError(holder, Restriction.droneBandwidth)
     self.assertIsNotNone(restrictionError)
     self.assertEqual(restrictionError.output, 40)
     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)