fix: use raw code without zero-padding, matching kyofilter_E behaviour
This commit is contained in:
+16
-27
@@ -17,14 +17,11 @@ class TestParseOptions:
|
||||
|
||||
|
||||
class TestGetAccountCode:
|
||||
def test_five_digit_code_zero_padded_to_eight(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MG12345"}) == "00012345"
|
||||
def test_five_digit_code_returned_as_is(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MG39321"}) == "39321"
|
||||
|
||||
def test_one_digit_code_zero_padded(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MG1"}) == "00000001"
|
||||
|
||||
def test_eight_digit_code_unchanged(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MG12345678"}) == "12345678"
|
||||
def test_one_digit_code_returned_as_is(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MG1"}) == "1"
|
||||
|
||||
def test_default_returns_none(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "Default"}) is None
|
||||
@@ -38,9 +35,6 @@ class TestGetAccountCode:
|
||||
def test_non_numeric_code_returns_none(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MGabc45"}) is None
|
||||
|
||||
def test_nine_digit_code_returns_none(self):
|
||||
assert kyofilter.get_account_code({"KmManagment": "MG123456789"}) is None
|
||||
|
||||
|
||||
class TestProcessStream:
|
||||
def _stream(self, text):
|
||||
@@ -53,38 +47,33 @@ class TestProcessStream:
|
||||
ps = "%!PS\n%%BeginSetup\n%%EndSetup\n%%Page: 1 1\n"
|
||||
assert self._collect(ps, None) == ps.encode()
|
||||
|
||||
def test_injects_before_end_setup(self):
|
||||
def test_injects_raw_code_before_end_setup(self):
|
||||
ps = "%!PS\n%%BeginSetup\n%%EndSetup\n%%Page: 1 1\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
assert b"(00012345) statusdict /setmanagementnumber get exec\n%%EndSetup\n" in result
|
||||
result = self._collect(ps, "39321")
|
||||
assert b"(39321) statusdict /setmanagementnumber get exec\n%%EndSetup\n" in result
|
||||
|
||||
def test_end_setup_preserved_after_injection(self):
|
||||
ps = "%!PS\n%%BeginSetup\n%%EndSetup\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
result = self._collect(ps, "39321")
|
||||
assert b"%%EndSetup\n" in result
|
||||
|
||||
def test_fallback_injects_before_first_page_when_no_end_setup(self):
|
||||
ps = "%!PS\n%%Page: 1 1\nshowpage\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
assert b"(00012345) statusdict /setmanagementnumber get exec\n%%Page: 1 1\n" in result
|
||||
result = self._collect(ps, "39321")
|
||||
assert b"(39321) statusdict /setmanagementnumber get exec\n%%Page: 1 1\n" in result
|
||||
|
||||
def test_injects_only_once(self):
|
||||
ps = "%!PS\n%%BeginSetup\n%%EndSetup\n%%Page: 1 1\n%%Page: 2 1\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
result = self._collect(ps, "39321")
|
||||
assert result.count(b"setmanagementnumber") == 1
|
||||
|
||||
def test_content_before_injection_point_preserved(self):
|
||||
ps = "%!PS\n%%BeginSetup\n/mydict 10 dict def\n%%EndSetup\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
def test_content_preserved(self):
|
||||
ps = "%!PS\n%%BeginSetup\n/mydict 10 dict def\n%%EndSetup\nshowpage\n"
|
||||
result = self._collect(ps, "39321")
|
||||
assert b"/mydict 10 dict def\n" in result
|
||||
|
||||
def test_content_after_injection_point_preserved(self):
|
||||
ps = "%!PS\n%%BeginSetup\n%%EndSetup\nshowpage\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
assert b"showpage\n" in result
|
||||
|
||||
def test_warns_when_no_injection_point(self, capsys):
|
||||
ps = "%!PS\nshowpage\n"
|
||||
self._collect(ps, "00012345")
|
||||
captured = capsys.readouterr()
|
||||
assert "WARNING" in captured.err
|
||||
self._collect(ps, "39321")
|
||||
assert "WARNING" in capsys.readouterr().err
|
||||
|
||||
Reference in New Issue
Block a user