diff --git a/src/lob_hlpr/hlpr.py b/src/lob_hlpr/hlpr.py index 087d914..ba316fb 100644 --- a/src/lob_hlpr/hlpr.py +++ b/src/lob_hlpr/hlpr.py @@ -260,6 +260,8 @@ def parse_dmc(dmc): # This: MPP-M0011554-OR019504_1-00781 article_number = chunks.pop(1) # Changes to MPP-OR019504_1-00781 + if chunks[0] != "MPP": + raise ValueError(f"Invalid DMC format: {dmc}, must start with MPP") # We want the OR019504 part erp_prod_number = chunks[0] + "-" + re.split("_", chunks[1])[0] diff --git a/tests/test_lob_hlpr.py b/tests/test_lob_hlpr.py index 2256734..2e422e8 100644 --- a/tests/test_lob_hlpr.py +++ b/tests/test_lob_hlpr.py @@ -26,6 +26,8 @@ def test_parse_dmc_fail(): """Test failing branches of the parse_dmc function.""" with pytest.raises(IndexError): hlp.parse_dmc("MPP-OR023282_1") + with pytest.raises(ValueError): + hlp.parse_dmc("PP-OR023282_1") # A bit of looking through a hex file and manual parsing allows me to provide