示例#1
0
 def test_match_full_wrong_prefix(self):
     """
     Tests matching a full system name, with the location prefix but a wrong one.
     """
     system = System(1, 'System Name', 'Beta', 5000, 5000, 'blue dwarf', '')
     ndf = NameDispFilter('Alpha System Name', False)
     self.assertEqual(ndf.approve(system), False)
示例#2
0
 def test_no_match_quasispace(self):
     """
     Test not matching a quasispace portal
     """
     q = Quasispace(5000, 5000, 5000, 5000, 'C')
     ndf = NameDispFilter('Quasispace Exit F', False)
     self.assertEqual(ndf.approve(q), False)
示例#3
0
 def test_match_lc_uc(self):
     """
     Tests matching a lowercase system name with uppercase search
     """
     system = System(1, 'system', 'Alpha', 5000, 5000, 'blue dwarf', '')
     ndf = NameDispFilter('SYSTEM', False)
     self.assertEqual(ndf.approve(system), True)
示例#4
0
 def test_no_match(self):
     """
     Attempting to match a system which fails
     """
     system = System(1, 'Zoq-Fot-Pik', 'Alpha', 5000, 5000, 'blue dwarf',
                     '')
     ndf = NameDispFilter('Ur-Quan', False)
     self.assertEqual(ndf.approve(system), False)
示例#5
0
 def test_match_extra_lc_uc(self):
     """
     Tests matching extra text with lowercase extra and uppercase search
     """
     system = System(1, 'System Name', 'Alpha', 5000, 5000, 'blue dwarf',
                     'extra')
     ndf = NameDispFilter('EXTRA', True)
     self.assertEqual(ndf.approve(system), True)
示例#6
0
 def test_match_extra(self):
     """
     Tests matching based on extra text
     """
     system = System(1, 'System Name', 'Alpha', 5000, 5000, 'blue dwarf',
                     'Zoq-Fot-Pik Homeworld')
     ndf = NameDispFilter('zoq', True)
     self.assertEqual(ndf.approve(system), True)
示例#7
0
 def test_match_substring(self):
     """
     Tests matching a substring of a system name
     """
     system = System(1, 'System Name', 'Alpha', 5000, 5000, 'blue dwarf',
                     '')
     ndf = NameDispFilter('Stem', False)
     self.assertEqual(ndf.approve(system), True)
示例#8
0
 def test_no_match_quasispace_extra(self):
     """
     Test not matching a quasispace portal, when the filter is allowed
     to search for extra text
     """
     q = Quasispace(5000, 5000, 5000, 5000, 'C')
     ndf = NameDispFilter('Quasispace Exit F', True)
     self.assertEqual(ndf.approve(q), False)
示例#9
0
 def test_match_extra_without_flag(self):
     """
     Tests matching based on extra text, but without the extra text being a valid
     source
     """
     system = System(1, 'System Name', 'Alpha', 5000, 5000, 'blue dwarf',
                     'Zoq-Fot-Pik Homeworld')
     ndf = NameDispFilter('zoq', False)
     self.assertEqual(ndf.approve(system), False)
示例#10
0
 def test_init(self):
     """
     Tests our basic initialization routine
     """
     ndf = NameDispFilter('Name', True)
     self.assertEqual(ndf.name, 'name')
     self.assertEqual(ndf.specialchecked, True)
示例#11
0
 def test_approve_single_match(self):
     """
     Tests approving a system with a single filter which matches
     """
     s = System(1, 'System', 'Alpha', 5000, 5000, 'blue dwarf', '')
     self.f.add(NameDispFilter('alpha system', False))
     self.assertEqual(self.f.approve(s), True)
示例#12
0
 def test_process_aggregates_three_systems_two_disp_one_agg(self):
     """
     Process aggregates when there are three systems - two match the display
     filter and one is cut out by the aggregate.
     """
     f = SafetyAggFilter()
     f.set_weather(2)
     self.s.aggfilter.add(f)
     self.s.dispfilter.add(NameDispFilter('System', False))
     sys1 = self.s.add_system(1, 'System', 'Alpha', 5000, 5000,
                              'blue dwarf', '')
     sys1.addplanet(
         Planet(1, 'Acid', 'Acid World', 3, 3, 100, 1, 10, 5,
                MinData(base=3, )))
     sys2 = self.s.add_system(2, 'System', 'Beta', 5500, 5500, 'blue dwarf',
                              '')
     sys2.addplanet(
         Planet(2, 'Acid', 'Acid World', 1, 1, 100, 1, 5, 0,
                MinData(radioactive=3, )))
     sys3 = self.s.add_system(3, 'Serpentis', 'Gamma', 6000, 6000,
                              'blue dwarf', '')
     sys3.addplanet(
         Planet(3, 'Acid', 'Acid World', 1, 1, 100, 1, 0, 0,
                MinData(exotic=3, )))
     self.s.process_aggregates()
     self.assertEqual(self.s.agg_min_value, 0)
     self.assertEqual(self.s.agg_max_value, 24)
     self.assertEqual(self.s.agg_spread, 24)
     self.assertEqual(self.s.bio_agg_min_value, 0)
     self.assertEqual(self.s.bio_agg_max_value, 5)
     self.assertEqual(self.s.bio_agg_spread, 5)
示例#13
0
 def test_add_two_filters(self):
     """
     Tests adding two new filters to the chain
     """
     s = System(1, 'System', 'Alpha', 5000, 5000, 'blue dwarf', '')
     self.f.add(NameDispFilter('Hello', False))
     self.f.add(ProxDispFilter(s, 500))
     self.assertEqual(self.f.filtering(), True)
示例#14
0
 def test_approve_two_matches(self):
     """
     Tests approving a system with two filters which both match
     """
     s = System(1, 'System', 'Alpha', 5000, 5000, 'blue dwarf', '')
     s2 = System(2, 'System', 'Beta', 5100, 5100, 'red dwarf', '')
     self.f.add(NameDispFilter('alpha system', False))
     self.f.add(ProxDispFilter(s2, 500))
     self.assertEqual(self.f.approve(s), True)
示例#15
0
 def test_reset(self):
     """
     Tests resetting the filter
     """
     s = System(1, 'System', 'Alpha', 5000, 5000, 'blue dwarf', '')
     self.f.add(NameDispFilter('Hello', False))
     self.f.add(ProxDispFilter(s, 500))
     self.assertEqual(self.f.filtering(), True)
     self.f.reset()
     self.assertEqual(self.f.filtering(), False)
示例#16
0
 def test_approve_two_matches_first_fails(self):
     """
     Tests approving a system with two filters in which the first one
     fails.
     """
     s = System(1, 'System', 'Alpha', 5000, 5000, 'blue dwarf', '')
     s2 = System(2, 'System', 'Beta', 5100, 5100, 'red dwarf', '')
     self.f.add(NameDispFilter('ur-quan', False))
     self.f.add(ProxDispFilter(s2, 500))
     self.assertEqual(self.f.approve(s), False)
示例#17
0
 def test_process_aggregates_one_system_fails_display_filter(self):
     """
     Process aggregates when there is one system which fails the display
     filters
     """
     self.s.dispfilter.add(NameDispFilter('Yehat', False))
     sys = self.s.add_system(1, 'System', 'Alpha', 5000, 5000, 'blue dwarf',
                             '')
     sys.addplanet(
         Planet(1, 'Acid', 'Acid World', 1, 1, 100, 1, 10, 5,
                MinData(base=3, )))
     self.s.process_aggregates()
     self.assertEqual(self.s.agg_min_value, 0)
     self.assertEqual(self.s.agg_max_value, 0)
     self.assertEqual(self.s.agg_spread, 0)
     self.assertEqual(self.s.bio_agg_min_value, 0)
     self.assertEqual(self.s.bio_agg_max_value, 0)
     self.assertEqual(self.s.bio_agg_spread, 0)
示例#18
0
 def test_add_filter(self):
     """
     Tests adding a new filter to the chain
     """
     self.f.add(NameDispFilter('Hello', False))
     self.assertEqual(self.f.filtering(), True)