From e575a76d1d65a3173f4f6f933425dc6745dcd0e3 Mon Sep 17 00:00:00 2001 From: Alex Goodwin Date: Wed, 8 Nov 2023 01:23:19 +1000 Subject: [PATCH] Reject multiple research stations --- PyRoute/TradeCodes.py | 5 +++++ Tests/Hypothesis/testDeltaStar.py | 1 + 2 files changed, 6 insertions(+) diff --git a/PyRoute/TradeCodes.py b/PyRoute/TradeCodes.py index d11ebbfc3..bb3adc423 100644 --- a/PyRoute/TradeCodes.py +++ b/PyRoute/TradeCodes.py @@ -470,6 +470,11 @@ def is_well_formed(self): msg = "Residual code " + str(code) + " not in allowed residual list" return False, msg + research_stations = [code for code in self.codes if code.startswith('Rs')] + if 1 < len(research_stations): + msg = "At most one research station allowed" + return False, msg + result, msg = self._check_code_pairs_allowed() return result, msg diff --git a/Tests/Hypothesis/testDeltaStar.py b/Tests/Hypothesis/testDeltaStar.py index 779707077..ee25857ec 100644 --- a/Tests/Hypothesis/testDeltaStar.py +++ b/Tests/Hypothesis/testDeltaStar.py @@ -370,6 +370,7 @@ def test_canonicalise_cx_on_non_barren_worlds(self, starline): @example('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') @example('0101 0 A000400-0 As Ba { 0 } (001+0) [0000] - - A 000 0 NaHu G5 V') @example('0101 0 A000000-0 Cp Cp Cp Cp Cp Cp Cp Cp Cp Cp { 0 } (000+0) [0000] - - A 000 0 NaHu G5 V') + @example('0101 0 A000600-0 Cp Cx Cs Mr Da RsA RsB RsG { 0 } (000+0) [0000] - - A 000 0 NaHu G5 V') def test_canonicalise_from_regex_match_and_verify_idempotency(self, starline): sector = Sector(' Core', ' 0, 0') foo = DeltaStar.parse_line_into_star(starline, sector, 'fixed', 'fixed')