예제 #1
0
 def test_cache(self):
     ship_item = self.ch.type_(type_id=1)
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.subsystem_slot: 6}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.fit.subsystems.add(holder1)
     self.fit.subsystems.add(holder2)
     self.assertEqual(self.st.subsystem_slots.used, 2)
     self.assertEqual(self.st.subsystem_slots.total, 6)
     ship_holder.attributes[Attribute.subsystem_slot] = 4
     self.fit.subsystems.remove(holder1)
     self.assertEqual(self.st.subsystem_slots.used, 2)
     self.assertEqual(self.st.subsystem_slots.total, 6)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #2
0
 def test_multiple(self):
     item = self.ch.type_(type_id=1, attributes={})
     holder1 = Mock(state=State.active, item=item, spec=Module(1))
     holder2 = Mock(state=State.active, item=item, spec=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     holder1_volley = Mock(em=1.2,
                           thermal=2.3,
                           kinetic=3.4,
                           explosive=4.5,
                           total=5.6)
     holder2_volley = Mock(em=0,
                           thermal=4,
                           kinetic=2,
                           explosive=7.1,
                           total=99)
     holder1.get_nominal_volley.return_value = holder1_volley
     holder2.get_nominal_volley.return_value = holder2_volley
     stats_volley = self.st.get_nominal_volley()
     self.assertAlmostEqual(stats_volley.em, 1.2)
     self.assertAlmostEqual(stats_volley.thermal, 6.3)
     self.assertAlmostEqual(stats_volley.kinetic, 5.4)
     self.assertAlmostEqual(stats_volley.explosive, 11.6)
     self.assertAlmostEqual(stats_volley.total, 24.5)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #3
0
 def test_volatility(self):
     ship_item = self.ch.type_(type_id=1)
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.launcher_slots_left: 6}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={})
     item.slots = {Slot.launcher}
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.assertEqual(self.st.launcher_slots.used, 2)
     self.assertEqual(self.st.launcher_slots.total, 6)
     ship_holder.attributes[Attribute.launcher_slots_left] = 4
     self.untrack_holder(holder1)
     self.st._clear_volatile_attrs()
     self.assertEqual(self.st.launcher_slots.used, 1)
     self.assertEqual(self.st.launcher_slots.total, 4)
     self.set_ship(None)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #4
0
 def test_fail_excess_multiple(self):
     # Check that error works for multiple holders, and raised
     # only for those which lie out of bounds
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.fit.modules.low.append(holder1)
     self.fit.modules.low.append(holder2)
     self.fit.stats.low_slots.used = 2
     self.fit.stats.low_slots.total = 1
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.low_slot)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.low_slot)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.slots_max_allowed, 1)
     self.assertEqual(restriction_error2.slots_used, 2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #5
0
 def test_fail_excess_multiple_with_nones(self):
     # Make sure Nones are processed properly
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Module(1))
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Module(1))
     holder3 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Module(1))
     self.fit.modules.med.append(None)
     self.fit.modules.med.append(holder1)
     self.fit.modules.med.append(None)
     self.fit.modules.med.append(None)
     self.fit.modules.med.append(holder2)
     self.fit.modules.med.append(None)
     self.fit.modules.med.append(holder3)
     self.fit.stats.med_slots.used = 7
     self.fit.stats.med_slots.total = 3
     restriction_error1 = self.get_restriction_error(holder1, Restriction.medium_slot)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.medium_slot)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.slots_max_allowed, 3)
     self.assertEqual(restriction_error2.slots_used, 7)
     restriction_error3 = self.get_restriction_error(holder2, Restriction.medium_slot)
     self.assertIsNotNone(restriction_error3)
     self.assertEqual(restriction_error3.slots_max_allowed, 3)
     self.assertEqual(restriction_error3.slots_used, 7)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #6
0
 def test_fail_excess_all(self):
     # Make sure error is raised for all holders exceeding
     # their group restriction
     item = self.ch.type_(type_id=1,
                          group=6,
                          attributes={Attribute.max_group_online: 1})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.max_group, 1)
     self.assertEqual(restriction_error1.holder_group, 6)
     self.assertEqual(restriction_error1.group_holders, 2)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.max_group, 1)
     self.assertEqual(restriction_error2.holder_group, 6)
     self.assertEqual(restriction_error2.group_holders, 2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #7
0
 def test_pass_holder_none_group(self):
     # Check that holders with None group are not affected
     item = self.ch.type_(type_id=1,
                          group=None,
                          attributes={Attribute.max_group_online: 1})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #8
0
 def test_pass_holder_non_ship(self):
     # Holders not belonging to ship shouldn't be affected
     item = self.ch.type_(type_id=1,
                          group=12,
                          attributes={Attribute.max_group_online: 1})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=None,
                    spec_set=Module(1))
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=None,
                    spec_set=Module(1))
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #9
0
파일: test_cpu.py 프로젝트: Ebag333/eos
 def test_fail_excess_multiple(self):
     # When multiple consumers require less than cpu output
     # alone, but in sum want more than total output, it should
     # be erroneous situation
     item = self.ch.type_(type_id=1, attributes={Attribute.cpu: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder1.attributes = {Attribute.cpu: 25}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2.attributes = {Attribute.cpu: 20}
     self.track_holder(holder2)
     self.fit.stats.cpu.used = 45
     self.fit.stats.cpu.output = 40
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.cpu)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.output, 40)
     self.assertEqual(restriction_error1.total_use, 45)
     self.assertEqual(restriction_error1.holder_use, 25)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.cpu)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.output, 40)
     self.assertEqual(restriction_error2.total_use, 45)
     self.assertEqual(restriction_error2.holder_use, 20)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #10
0
 def test_fail_excess_multiple(self):
     # Check that error works for multiple holders
     item = self.ch.type_(type_id=1)
     item.slots = {Slot.turret}
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.fit.stats.turret_slots.used = 2
     self.fit.stats.turret_slots.total = 1
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.turret_slot)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.slots_max_allowed, 1)
     self.assertEqual(restriction_error1.slots_used, 2)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.turret_slot)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.slots_max_allowed, 1)
     self.assertEqual(restriction_error2.slots_used, 2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #11
0
파일: test_cpu.py 프로젝트: Ebag333/eos
 def test_mix_usage_zero(self):
     # If some holder has zero usage and cpu error is
     # still raised, check it's not raised for holder with
     # zero usage
     item = self.ch.type_(type_id=1, attributes={Attribute.cpu: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder1.attributes = {Attribute.cpu: 100}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2.attributes = {Attribute.cpu: 0}
     self.track_holder(holder2)
     self.fit.stats.cpu.used = 100
     self.fit.stats.cpu.output = 50
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.cpu)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.output, 50)
     self.assertEqual(restriction_error1.total_use, 100)
     self.assertEqual(restriction_error1.holder_use, 100)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.cpu)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #12
0
파일: test_cpu.py 프로젝트: Ebag333/eos
 def test_pass(self):
     # When total consumption is less than output,
     # no errors should be raised
     item = self.ch.type_(type_id=1, attributes={Attribute.cpu: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder1.attributes = {Attribute.cpu: 25}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2.attributes = {Attribute.cpu: 20}
     self.track_holder(holder2)
     self.fit.stats.cpu.used = 45
     self.fit.stats.cpu.output = 50
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.cpu)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.cpu)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #13
0
 def test_fail_other_holder_class(self):
     # Make sure holders of all classes are affected
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.subsystem_slot: 120})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.subsystem_index)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.holder_slot_index, 120)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.subsystem_index)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.holder_slot_index, 120)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #14
0
 def test_filter_mixed(self):
     item = self.ch.type_(type_id=1, attributes={})
     holder1 = Mock(state=State.active, item=item, spec=Module(1))
     holder2 = Mock(state=State.active, item=item, spec=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     holder1_dps = Mock(em=1.2,
                        thermal=2.3,
                        kinetic=3.4,
                        explosive=4.5,
                        total=5.6)
     holder2_dps = Mock(em=0, thermal=4, kinetic=2, explosive=7.1, total=99)
     holder1.get_nominal_dps.return_value = holder1_dps
     holder2.get_nominal_dps.return_value = holder2_dps
     stats_dps = self.st.get_nominal_dps(
         holder_filter=lambda h: h is holder2)
     self.assertAlmostEqual(stats_dps.em, 0)
     self.assertAlmostEqual(stats_dps.thermal, 4)
     self.assertAlmostEqual(stats_dps.kinetic, 2)
     self.assertAlmostEqual(stats_dps.explosive, 7.1)
     self.assertAlmostEqual(stats_dps.total, 13.1)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #15
0
 def test_none_and_data(self):
     # As container for damage dealers is not ordered,
     # this test may be unreliable (even if there's issue,
     # it won't fail each run)
     item = self.ch.type_(type_id=1, attributes={})
     holder1 = Mock(state=State.active, item=item, spec=Module(1))
     holder2 = Mock(state=State.active, item=item, spec=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     holder1_dps = Mock(em=1.2,
                        thermal=2.3,
                        kinetic=3.4,
                        explosive=4.5,
                        total=5.6)
     holder2_dps = Mock(em=None,
                        thermal=None,
                        kinetic=None,
                        explosive=None,
                        total=None)
     holder1.get_nominal_dps.return_value = holder1_dps
     holder2.get_nominal_dps.return_value = holder2_dps
     stats_dps = self.st.get_nominal_dps()
     self.assertAlmostEqual(stats_dps.em, 1.2)
     self.assertAlmostEqual(stats_dps.thermal, 2.3)
     self.assertAlmostEqual(stats_dps.kinetic, 3.4)
     self.assertAlmostEqual(stats_dps.explosive, 4.5)
     self.assertAlmostEqual(stats_dps.total, 11.4)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #16
0
파일: test_med.py 프로젝트: Ebag333/eos
 def test_volatility(self):
     ship_item = self.ch.type_(type_id=1)
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.med_slots: 6}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.fit.modules.med.append(holder1)
     self.fit.modules.med.append(holder2)
     self.assertEqual(self.st.med_slots.used, 2)
     self.assertEqual(self.st.med_slots.total, 6)
     ship_holder.attributes[Attribute.med_slots] = 4
     self.fit.modules.med.remove(holder1)
     self.st._clear_volatile_attrs()
     self.assertEqual(self.st.med_slots.used, 1)
     self.assertEqual(self.st.med_slots.total, 4)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #17
0
 def test_volatility(self):
     ship_item = self.ch.type_(type_id=1,
                               attributes={Attribute.upgrade_capacity: 10})
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.upgrade_capacity: 50}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={Attribute.upgrade_cost: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder1.attributes = {Attribute.upgrade_cost: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2.attributes = {Attribute.upgrade_cost: 30}
     self.track_holder(holder2)
     self.assertEqual(self.st.calibration.used, 80)
     self.assertEqual(self.st.calibration.output, 50)
     holder1.attributes[Attribute.upgrade_cost] = 10
     ship_holder.attributes[Attribute.upgrade_capacity] = 60
     self.st._clear_volatile_attrs()
     self.assertEqual(self.st.calibration.used, 40)
     self.assertEqual(self.st.calibration.output, 60)
     self.set_ship(None)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #18
0
 def test_pass_greater(self):
     item = self.ch.type_(type_id=1)
     item.slots = {Slot.turret}
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.fit.stats.turret_slots.used = 2
     self.fit.stats.turret_slots.total = 5
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.turret_slot)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.turret_slot)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #19
0
 def test_mix_excess_original(self):
     # Check that original item attributes are used
     item1 = self.ch.type_(type_id=1,
                           group=61,
                           attributes={Attribute.max_group_online: 1})
     holder1 = Mock(state=State.online,
                    item=item1,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder1.attributes = {Attribute.max_group_online: 2}
     self.track_holder(holder1)
     item2 = self.ch.type_(type_id=2,
                           group=61,
                           attributes={Attribute.max_group_online: 2})
     holder2 = Mock(state=State.online,
                    item=item2,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2.attributes = {Attribute.max_group_online: 1}
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.max_group, 1)
     self.assertEqual(restriction_error1.holder_group, 61)
     self.assertEqual(restriction_error1.group_holders, 2)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #20
0
 def test_pass(self):
     # Make sure no errors are raised when number of added
     # items doesn't exceed any restrictions
     item = self.ch.type_(type_id=1,
                          group=860,
                          attributes={Attribute.max_group_online: 2})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #21
0
 def test_mix_excess_one(self):
     # Make sure error is raised for just holders which excess
     # restriction, even if both are from the same group
     item1 = self.ch.type_(type_id=1,
                           group=92,
                           attributes={Attribute.max_group_online: 1})
     holder1 = Mock(state=State.online,
                    item=item1,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     item2 = self.ch.type_(type_id=2,
                           group=92,
                           attributes={Attribute.max_group_online: 2})
     holder2 = Mock(state=State.online,
                    item=item2,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.max_group, 1)
     self.assertEqual(restriction_error1.holder_group, 92)
     self.assertEqual(restriction_error1.group_holders, 2)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #22
0
 def test_pass_state(self):
     # No errors should occur if holders are not active+
     item = self.ch.type_(type_id=1,
                          group=886,
                          attributes={Attribute.max_group_online: 1})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.track_holder(holder2)
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.max_group_online)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.max_group_online)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #23
0
 def test_cache(self):
     ship_item = self.ch.type_(type_id=1,
                               attributes={Attribute.power_output: 10})
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.power_output: 50}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={Attribute.power: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder1.attributes = {Attribute.power: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2.attributes = {Attribute.power: 30}
     self.track_holder(holder2)
     self.assertEqual(self.st.powergrid.used, 80)
     self.assertEqual(self.st.powergrid.output, 50)
     holder1.attributes[Attribute.power] = 10
     ship_holder.attributes[Attribute.power_output] = 60
     self.assertEqual(self.st.powergrid.used, 80)
     self.assertEqual(self.st.powergrid.output, 50)
     self.set_ship(None)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #24
0
파일: test_cpu.py 프로젝트: Ebag333/eos
 def test_use_negative(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.cpu: 0})
     holder1 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=Module(1))
     holder1.attributes = {Attribute.cpu: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=Module(1))
     holder2.attributes = {Attribute.cpu: -30}
     self.track_holder(holder2)
     self.assertEqual(self.st.cpu.used, 20)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #25
0
 def test_pass_equal(self):
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Module(1))
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Module(1))
     self.fit.modules.med.append(holder1)
     self.fit.modules.med.append(holder2)
     self.fit.stats.med_slots.used = 2
     self.fit.stats.med_slots.total = 2
     restriction_error1 = self.get_restriction_error(holder1, Restriction.medium_slot)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.medium_slot)
     self.assertIsNone(restriction_error2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #26
0
 def test_use_multiple(self):
     item = self.ch.type_(type_id=1, attributes={})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.ship,
                    spec_set=Module(1))
     self.fit.subsystems.add(holder1)
     self.fit.subsystems.add(holder2)
     self.assertEqual(self.st.subsystem_slots.used, 2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
예제 #27
0
 def test_fail_charge_no_attrib(self):
     charge_item = self.ch.type_(type_id=1, attributes={})
     charge_holder = Mock(state=State.offline,
                          item=charge_item,
                          _domain=None,
                          spec_set=Charge(1))
     container_item = self.ch.type_(type_id=2,
                                    attributes={Attribute.charge_size: 3})
     container_holder = Mock(state=State.offline,
                             item=container_item,
                             _domain=Domain.ship,
                             spec_set=Module(1))
     container_holder.charge = charge_holder
     charge_holder.container = container_holder
     self.track_holder(container_holder)
     self.track_holder(charge_holder)
     restriction_error1 = self.get_restriction_error(
         container_holder, Restriction.charge_size)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         charge_holder, Restriction.charge_size)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.allowed_size, 3)
     self.assertEqual(restriction_error2.holder_size, None)
     self.untrack_holder(container_holder)
     self.untrack_holder(charge_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #28
0
 def test_pass_multiple(self):
     charge_item = self.ch.type_(type_id=1, group=1008)
     charge_holder = Mock(state=State.offline,
                          item=charge_item,
                          _domain=None,
                          spec_set=Charge(1))
     container_item = self.ch.type_(type_id=2,
                                    attributes={
                                        Attribute.charge_group_3: 56,
                                        Attribute.charge_group_5: 1008
                                    })
     container_holder = Mock(state=State.offline,
                             item=container_item,
                             _domain=Domain.ship,
                             spec_set=Module(1))
     container_holder.charge = charge_holder
     charge_holder.container = container_holder
     self.track_holder(container_holder)
     self.track_holder(charge_holder)
     restriction_error1 = self.get_restriction_error(
         container_holder, Restriction.charge_group)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         charge_holder, Restriction.charge_group)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(container_holder)
     self.untrack_holder(charge_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #29
0
 def test_fail_group3(self):
     charge_item = self.ch.type_(type_id=1, group=1008)
     charge_holder = Mock(state=State.offline,
                          item=charge_item,
                          _domain=None,
                          spec_set=Charge(1))
     container_item = self.ch.type_(
         type_id=2, attributes={Attribute.charge_group_3: 3})
     container_holder = Mock(state=State.offline,
                             item=container_item,
                             _domain=Domain.ship,
                             spec_set=Module(1))
     container_holder.charge = charge_holder
     charge_holder.container = container_holder
     self.track_holder(container_holder)
     self.track_holder(charge_holder)
     restriction_error1 = self.get_restriction_error(
         container_holder, Restriction.charge_group)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         charge_holder, Restriction.charge_group)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(len(restriction_error2.allowed_groups), 1)
     self.assertIn(3, restriction_error2.allowed_groups)
     self.assertEqual(restriction_error2.holder_group, 1008)
     self.untrack_holder(container_holder)
     self.untrack_holder(charge_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
예제 #30
0
 def test_pass_original_attribs(self):
     # Make sure original item attributes are used
     charge_item = self.ch.type_(type_id=1,
                                 attributes={Attribute.charge_size: 2})
     charge_holder = Mock(state=State.offline,
                          item=charge_item,
                          _domain=None,
                          spec_set=Charge(1))
     charge_holder.attributes = {Attribute.charge_size: 1}
     container_item = self.ch.type_(type_id=2,
                                    attributes={Attribute.charge_size: 2})
     container_holder = Mock(state=State.offline,
                             item=container_item,
                             _domain=Domain.ship,
                             spec_set=Module(1))
     container_holder.attributes = {Attribute.charge_size: 3}
     container_holder.charge = charge_holder
     charge_holder.container = container_holder
     self.track_holder(container_holder)
     self.track_holder(charge_holder)
     restriction_error1 = self.get_restriction_error(
         container_holder, Restriction.charge_size)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         charge_holder, Restriction.charge_size)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(container_holder)
     self.untrack_holder(charge_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()