コード例 #1
0
 def test_mix_usage_zero(self):
     # If some holder has zero usage and bandwidth error is
     # still raised, check it's not raised for holder with
     # zero usage
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.drone_bandwidth_used: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.drone_bandwidth_used: 100}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.drone_bandwidth_used: 0}
     self.track_holder(holder2)
     self.fit.stats.drone_bandwidth.used = 100
     self.fit.stats.drone_bandwidth.output = 50
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.drone_bandwidth)
     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.drone_bandwidth)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #2
0
 def test_volatility(self):
     char_item = self.ch.type_(type_id=1)
     char_holder = Mock(state=State.offline,
                        item=char_item,
                        _domain=None,
                        spec_set=Character(1))
     char_holder.attributes = {Attribute.max_active_drones: 6}
     self.set_character(char_holder)
     item = self.ch.type_(type_id=2, attributes={})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.assertEqual(self.st.launched_drones.used, 2)
     self.assertEqual(self.st.launched_drones.total, 6)
     char_holder.attributes[Attribute.max_active_drones] = 4
     self.untrack_holder(holder1)
     self.st._clear_volatile_attrs()
     self.assertEqual(self.st.launched_drones.used, 1)
     self.assertEqual(self.st.launched_drones.total, 4)
     self.set_character(None)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
コード例 #3
0
 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.drone_bandwidth_used: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.drone_bandwidth_used: 25}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.drone_bandwidth_used: 20}
     self.track_holder(holder2)
     self.fit.stats.drone_bandwidth.used = 45
     self.fit.stats.drone_bandwidth.output = 50
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.drone_bandwidth)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(
         holder2, Restriction.drone_bandwidth)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #4
0
 def test_cache(self):
     ship_item = self.ch.type_(type_id=1,
                               attributes={Attribute.drone_capacity: 10})
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.drone_capacity: 50}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={Attribute.volume: 0})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.volume: 50}
     self.fit.drones.add(holder1)
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.volume: 30}
     self.fit.drones.add(holder2)
     self.track_holder(holder2)
     self.assertEqual(self.st.dronebay.used, 80)
     self.assertEqual(self.st.dronebay.output, 50)
     holder1.attributes[Attribute.volume] = 10
     ship_holder.attributes[Attribute.drone_capacity] = 60
     self.assertEqual(self.st.dronebay.used, 80)
     self.assertEqual(self.st.dronebay.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()
コード例 #5
0
 def test_volatility(self):
     ship_item = self.ch.type_(type_id=1,
                               attributes={Attribute.drone_bandwidth: 10})
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.drone_bandwidth: 50}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2,
                          attributes={Attribute.drone_bandwidth_used: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.drone_bandwidth_used: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.drone_bandwidth_used: 30}
     self.track_holder(holder2)
     self.assertEqual(self.st.drone_bandwidth.used, 80)
     self.assertEqual(self.st.drone_bandwidth.output, 50)
     holder1.attributes[Attribute.drone_bandwidth_used] = 10
     ship_holder.attributes[Attribute.drone_bandwidth] = 60
     self.st._clear_volatile_attrs()
     self.assertEqual(self.st.drone_bandwidth.used, 40)
     self.assertEqual(self.st.drone_bandwidth.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()
コード例 #6
0
ファイル: test_drone_group.py プロジェクト: Ebag333/eos
 def test_pass_match_combination(self):
     # Check that no error raised when drone of group
     # matching to any of two restriction attributes
     # is added
     item = self.ch.type_(type_id=1, group=53)
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     self.track_holder(holder)
     ship_item = self.ch.type_(type_id=2,
                               attributes={
                                   Attribute.allowed_drone_group_1: 907,
                                   Attribute.allowed_drone_group_2: 53
                               })
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     self.set_ship(ship_holder)
     restriction_error = self.get_restriction_error(holder,
                                                    Restriction.drone_group)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #7
0
ファイル: test_drone_group.py プロジェクト: Ebag333/eos
 def test_fail_drone_none(self):
     # Check that drone from None group is subject
     # to restriction
     item = self.ch.type_(type_id=1, group=None)
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     self.track_holder(holder)
     ship_item = self.ch.type_(
         type_id=2, attributes={Attribute.allowed_drone_group_1: 1896})
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     self.set_ship(ship_holder)
     restriction_error = self.get_restriction_error(holder,
                                                    Restriction.drone_group)
     self.assertIsNotNone(restriction_error)
     self.assertCountEqual(restriction_error.allowed_groups, (1896, ))
     self.assertEqual(restriction_error.holder_group, None)
     self.untrack_holder(holder)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #8
0
ファイル: test_drone_group.py プロジェクト: Ebag333/eos
 def test_fail_mismatch_original(self):
     # Check that error is returned on attempt
     # to add drone from group mismatching to
     # original restriction attribute, but matching
     # to modified restriction attribute. Effectively
     # we check that original attribute value is taken
     item = self.ch.type_(type_id=1, group=37)
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     self.track_holder(holder)
     ship_item = self.ch.type_(
         type_id=2, attributes={Attribute.allowed_drone_group_1: 59})
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     ship_holder.attributes = {Attribute.allowed_drone_group_1: 37}
     self.set_ship(ship_holder)
     restriction_error = self.get_restriction_error(holder,
                                                    Restriction.drone_group)
     self.assertIsNotNone(restriction_error)
     self.assertCountEqual(restriction_error.allowed_groups, (59, ))
     self.assertEqual(restriction_error.holder_group, 37)
     self.untrack_holder(holder)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #9
0
 def test_pass_equal(self):
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder2 = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.fit.stats.launched_drones.used = 2
     self.fit.stats.launched_drones.total = 2
     restriction_error1 = self.get_restriction_error(holder1, Restriction.launched_drone)
     self.assertIsNone(restriction_error1)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.launched_drone)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #10
0
ファイル: test_drone_group.py プロジェクト: Ebag333/eos
 def test_fail_mismatch_combined(self):
     # Check that error is returned on attempt
     # to add drone from group mismatching to
     # both restriction attributes
     item = self.ch.type_(type_id=1, group=803)
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     self.track_holder(holder)
     ship_item = self.ch.type_(type_id=2,
                               attributes={
                                   Attribute.allowed_drone_group_1: 48,
                                   Attribute.allowed_drone_group_2: 106
                               })
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     self.set_ship(ship_holder)
     restriction_error = self.get_restriction_error(holder,
                                                    Restriction.drone_group)
     self.assertIsNotNone(restriction_error)
     self.assertCountEqual(restriction_error.allowed_groups, (48, 106))
     self.assertEqual(restriction_error.holder_group, 803)
     self.untrack_holder(holder)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #11
0
 def test_use_multiple(self):
     item = self.ch.type_(type_id=1, attributes={})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.assertEqual(self.st.launched_drones.used, 2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
コード例 #12
0
 def test_use_single_no_rounding(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 55.5555555555}
     self.fit.drones.add(holder)
     self.track_holder(holder)
     self.assertEqual(self.st.dronebay.used, 55.5555555555)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
コード例 #13
0
 def test_use_multiple(self):
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.drone_bandwidth_used: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.drone_bandwidth_used: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.drone_bandwidth_used: 30}
     self.track_holder(holder2)
     self.assertEqual(self.st.drone_bandwidth.used, 80)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
コード例 #14
0
 def test_use_other_class(self):
     # Make sure holders placed to other containers are unaffected
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 30}
     self.fit.rigs.add(holder)
     self.track_holder(holder)
     self.assertEqual(self.st.dronebay.used, 0)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
コード例 #15
0
 def test_use_negative(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder1 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.volume: 50}
     self.fit.drones.add(holder1)
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.volume: -30}
     self.fit.drones.add(holder2)
     self.track_holder(holder2)
     self.assertEqual(self.st.dronebay.used, 20)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
コード例 #16
0
 def test_fail_excess_multiple(self):
     # Check that error works for multiple holders
     item = self.ch.type_(type_id=1)
     holder1 = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder2 = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     self.track_holder(holder1)
     self.track_holder(holder2)
     self.fit.stats.launched_drones.used = 2
     self.fit.stats.launched_drones.total = 1
     restriction_error1 = self.get_restriction_error(holder1, Restriction.launched_drone)
     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.launched_drone)
     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()
コード例 #17
0
 def test_pass_other_container(self):
     # Make sure holders placed to other containers are unaffected
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 50}
     self.fit.rigs.add(holder)
     self.track_holder(holder)
     self.fit.stats.dronebay.used = 50
     self.fit.stats.dronebay.output = 40
     restriction_error = self.get_restriction_error(holder, Restriction.dronebay_volume)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #18
0
 def test_fail_excess_signle(self):
     # Check that error is raised when number of used
     # slots exceeds slot amount provided by character
     item = self.ch.type_(type_id=1)
     holder = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     self.track_holder(holder)
     self.fit.stats.launched_drones.used = 1
     self.fit.stats.launched_drones.total = 0
     restriction_error = self.get_restriction_error(holder, Restriction.launched_drone)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.slots_max_allowed, 0)
     self.assertEqual(restriction_error.slots_used, 1)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #19
0
 def test_fail_excess_signle_undefined_output(self):
     # When stats module does not specify total slot amount,
     # make sure it's assumed to be 0
     item = self.ch.type_(type_id=1)
     holder = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     self.track_holder(holder)
     self.fit.stats.launched_drones.used = 1
     self.fit.stats.launched_drones.total = None
     restriction_error = self.get_restriction_error(holder, Restriction.launched_drone)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.slots_max_allowed, 0)
     self.assertEqual(restriction_error.slots_used, 1)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #20
0
 def test_fail_excess_multiple(self):
     # When multiple consumers require less than bandwidth output
     # alone, but in sum want more than total output, it should
     # be erroneous situation
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.drone_bandwidth_used: 0})
     holder1 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder1.attributes = {Attribute.drone_bandwidth_used: 25}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online,
                    item=item,
                    _domain=Domain.space,
                    spec_set=Drone(1))
     holder2.attributes = {Attribute.drone_bandwidth_used: 20}
     self.track_holder(holder2)
     self.fit.stats.drone_bandwidth.used = 45
     self.fit.stats.drone_bandwidth.output = 40
     restriction_error1 = self.get_restriction_error(
         holder1, Restriction.drone_bandwidth)
     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.drone_bandwidth)
     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()
コード例 #21
0
ファイル: test_drone_group.py プロジェクト: Ebag333/eos
 def test_pass_no_ship(self):
     # Check that restriction isn't applied
     # when fit doesn't have ship
     item = self.ch.type_(type_id=1, group=None)
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     self.track_holder(holder)
     restriction_error = self.get_restriction_error(holder,
                                                    Restriction.drone_group)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #22
0
 def test_pass_no_original_attr(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
     item = self.ch.type_(type_id=1)
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 100}
     self.fit.drones.add(holder)
     self.track_holder(holder)
     self.fit.stats.dronebay.used = 100
     self.fit.stats.dronebay.output = 50
     restriction_error = self.get_restriction_error(holder, Restriction.dronebay_volume)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #23
0
 def test_fail_excess_modified(self):
     # Make sure modified volume values are taken
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 40})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 100}
     self.fit.drones.add(holder)
     self.track_holder(holder)
     self.fit.stats.dronebay.used = 100
     self.fit.stats.dronebay.output = 50
     restriction_error = self.get_restriction_error(holder, Restriction.dronebay_volume)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.output, 50)
     self.assertEqual(restriction_error.total_use, 100)
     self.assertEqual(restriction_error.holder_use, 100)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #24
0
 def test_pass_state(self):
     # When holder isn't online, it shouldn't consume anything
     item = self.ch.type_(type_id=1,
                          attributes={Attribute.drone_bandwidth_used: 0})
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     holder.attributes = {Attribute.drone_bandwidth_used: 50}
     self.track_holder(holder)
     self.fit.stats.drone_bandwidth.used = 50
     self.fit.stats.drone_bandwidth.output = 40
     restriction_error = self.get_restriction_error(
         holder, Restriction.drone_bandwidth)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #25
0
 def test_fail_excess_single_undefined_output(self):
     # When stats module does not specify output, make sure
     # it's assumed to be 0
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 5}
     self.fit.drones.add(holder)
     self.track_holder(holder)
     self.fit.stats.dronebay.used = 5
     self.fit.stats.dronebay.output = None
     restriction_error = self.get_restriction_error(holder, Restriction.dronebay_volume)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.output, 0)
     self.assertEqual(restriction_error.total_use, 5)
     self.assertEqual(restriction_error.holder_use, 5)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #26
0
 def test_fail_excess_single(self):
     # When ship provides drone bay volume, but single consumer
     # demands for more, error should be raised
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 50}
     self.fit.drones.add(holder)
     self.track_holder(holder)
     self.fit.stats.dronebay.used = 50
     self.fit.stats.dronebay.output = 40
     restriction_error = self.get_restriction_error(holder, Restriction.dronebay_volume)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.output, 40)
     self.assertEqual(restriction_error.total_use, 50)
     self.assertEqual(restriction_error.holder_use, 50)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #27
0
ファイル: test_drone_group.py プロジェクト: Ebag333/eos
 def test_pass_ship_no_restriction(self):
     # Check that restriction isn't applied
     # when fit has ship, but without restriction
     # attribute
     item = self.ch.type_(type_id=1, group=71)
     holder = Mock(state=State.offline,
                   item=item,
                   _domain=Domain.space,
                   spec_set=Drone(1))
     self.track_holder(holder)
     ship_item = self.ch.type_(type_id=2)
     ship_holder = Mock(state=State.offline,
                        item=ship_item,
                        _domain=None,
                        spec_set=Ship(1))
     self.set_ship(ship_holder)
     restriction_error = self.get_restriction_error(holder,
                                                    Restriction.drone_group)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
コード例 #28
0
 def test_mix_usage_negative(self):
     # If some holder has negative usage and drone bay error is
     # still raised, check it's not raised for holder with
     # negative usage
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder1.attributes = {Attribute.volume: 100}
     self.fit.drones.add(holder1)
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder2.attributes = {Attribute.volume: -10}
     self.fit.drones.add(holder2)
     self.track_holder(holder2)
     self.fit.stats.dronebay.used = 90
     self.fit.stats.dronebay.output = 50
     restriction_error1 = self.get_restriction_error(holder1, Restriction.dronebay_volume)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.output, 50)
     self.assertEqual(restriction_error1.total_use, 90)
     self.assertEqual(restriction_error1.holder_use, 100)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.dronebay_volume)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()