Skip to content

Commit

Permalink
Fix more test blowups
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberiaResurrection committed Nov 11, 2023
1 parent 21e7c63 commit 9010d5b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
4 changes: 4 additions & 0 deletions PyRoute/StatCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def add_pop_to_sophont(self, stats, star):
soph_code = sophont[0:4]
soph_pct = sophont[4:]

if 1 < len(soph_pct) and '(' == soph_code[0]:
soph_code = sophont[0:6]
soph_pct = sophont[6:]

if soph_pct == 'A':
default_soph = soph_code
continue
Expand Down
2 changes: 1 addition & 1 deletion PyRoute/TradeCodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _preprocess_initial_codes(self, initial_codes):
if 7 < len(raw) and '(' == raw[0] and ')' == raw[-2]: # Let older-style sophont codes through
codes.append(raw)
continue
if 2 == len(raw):
if 2 == len(raw) and ('W' == raw[1] or raw[1].isdigit()):
if 'C' == raw[0]: # Compact chirper population
pop = raw[1]
codes.append('Chir' + pop)
Expand Down
6 changes: 3 additions & 3 deletions Tests/testDeltaReduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def test_star_having_no_sector_attribute(self):
delta[sector.name] = sector

reducer = DeltaReduce(delta, args)
reducer.is_initial_state_uninteresting()
reducer.is_initial_state_uninteresting(reraise=True)

def test_population_balance_over_two_sectors(self):
args = self._make_args_no_line()
Expand All @@ -334,7 +334,7 @@ def test_population_balance_over_two_sectors(self):
self.assertEqual(2, len(delta), "Should only be two sectors in dictionary")

reducer = DeltaReduce(delta, args, args.interestingline, args.interestingtype)
reducer.is_initial_state_uninteresting()
reducer.is_initial_state_uninteresting(reraise=True)

def test_pax_and_trade_balance_over_reft_sector(self):
args = self._make_args_no_line()
Expand All @@ -345,7 +345,7 @@ def test_pax_and_trade_balance_over_reft_sector(self):
delta[sector.name] = sector

reducer = DeltaReduce(delta, args, args.interestingline, args.interestingtype)
reducer.is_initial_state_uninteresting()
reducer.is_initial_state_uninteresting(reraise=True)

def _make_args(self):
args = argparse.ArgumentParser(description='PyRoute input minimiser.')
Expand Down
2 changes: 1 addition & 1 deletion Tests/testDeltaStar.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_reduce_capitals(self):
("2123 Medurma A9D7954-C An Cs Hi { 3 } (G8E+1) [7C3A] - - 100 0 ImDv G0 V ",
"2123 Medurma A9D7954-C An Hi { 3 } (G8E+1) [7C3A] - - 100 0 ImDv G0 V "),
("2118 Capital A586A98-F Hi Cx (Syleans)5 { 4 } (H9G+4) [AE5F] BEFG NW - 605 15 ImSy G2 V Xb:1916 Xb:2021 Xb:2115 Xb:2216 Xb:2218",
"2118 Capital A586A98-F (Syleans)5 Hi { 4 } (H9G+4) [AE5F] BEFG NW - 605 15 ImSy G2 V Xb:1916 Xb:2021 Xb:2115 Xb:2216 Xb:2218 ")
"2118 Capital A586A98-F (Syle)5 Hi { 4 } (H9G+4) [AE5F] BEFG NW - 605 15 ImSy G2 V Xb:1916 Xb:2021 Xb:2115 Xb:2216 Xb:2218 ")
]

for chunk in check_list:
Expand Down
4 changes: 2 additions & 2 deletions Tests/testDeltaStarReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_drop_trade_codes_on_existing(self):
def test_reduce_routes_on_none(self):
src = "0216 Ambemshan A5457BC-B Ag Cp Pi Pz (Cassilldans) { 4 } (D6E+5) [AB8E] BCDF NS A 913 10 ImDa M3 V M6 V"

exp = "0216 Ambemshan A5457BC-B (Cassilldans) Ag Cp Pi Pz { 4 } (D6E+5) [AB8E] BCDF NS A 913 10 ImDa M3 V M6 V "
exp = "0216 Ambemshan A5457BC-B (Cass)W Ag Cp Pi Pz { 4 } (D6E+5) [AB8E] BCDF NS A 913 10 ImDa M3 V M6 V "
actual = DeltaStar.reduce(src, drop_routes=True)

self.assertEqual(exp, actual)
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_canonicalisation_of_dagudashaag_1722(self):

def test_canonicalisation_of_dagudashaag_2124(self):
src = "2123 Medurma A9D7954-C Hi An Cs Di(Miyavine) Asla1 S'mr0 { 3 } (G8E+1) [7C3A] BEF - - 823 12 ImDv G0 V Xb:1823 Xb:1926 Xb:2223 Xb:2225 Xb:2322"
exp = "2123 Medurma A9D7954-C An Asla1 Cs Di(Miyavine) Hi S'mr0 { 3 } (G8E+1) [7C3A] BEF - - 823 12 ImDv G0 V Xb:1823 Xb:1926 Xb:2223 Xb:2225 Xb:2322 "
exp = "2123 Medurma A9D7954-C (Miya)X An Asla1 Cs Hi S'mr0 { 3 } (G8E+1) [7C3A] BEF - - 823 12 ImDv G0 V Xb:1823 Xb:1926 Xb:2223 Xb:2225 Xb:2322 "

actual = DeltaStar.reduce(src)
self.assertEqual(exp, actual)
Expand Down
15 changes: 15 additions & 0 deletions Tests/testTradeCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,21 @@ def testVerifyCompactDroyneCodeProcessing(self):
self.assertEqual(1, len(code.sophont_list), "Compacted Droyne code should result in sophont")
self.assertEqual(expected, str(code))

def testSharedHomeworld(self):
line = 'Hi Pz (S\'mrii)7 (Kiakh\'iee)3 '
code = TradeCodes(line)
result, msg = code.is_well_formed()
self.assertTrue(result, msg)

self.assertEqual(2, len(code.sophont_list), "Shared homeworld should result in two sophont")
self.assertEqual(2, len(code.homeworld_list), "Shared homeworld should result in two homeworld entries")

expected_line = '(Kiak)3 (SXmr)7 Hi Pz'
self.assertEqual(expected_line, str(code), "Unexpected string representation")

nu_code = TradeCodes(str(code))
result, msg = nu_code.is_well_formed()
self.assertTrue(result, msg)

if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
Expand Down

0 comments on commit 9010d5b

Please sign in to comment.