Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.model.tests.test_identifiers::test_parse_swhid_parsing_error[swh:1:-Wrong format: There should be 4 mandatory values]
Failed

TEST RESULT

Run At
Nov 10 2020, 6:22 PM
Details
swhid = 'swh:1:' expected_error = 'Wrong format: There should be 4 mandatory values' @pytest.mark.parametrize( "swhid,expected_error", [ ("swh:1:cnt", "Wrong format: There should be 4 mandatory values"), ("swh:1:", "Wrong format: There should be 4 mandatory values"), ("swh:", "Wrong format: There should be 4 mandatory values"), ("swh:1:cnt:", "Wrong format: Identifier should be present"), ( "foo:1:cnt:abc8bc9d7a6bcf6db04f476d29314f157507d505", "Wrong format: only supported namespace is 'swh'", ), ( "swh:2:dir:def8bc9d7a6bcf6db04f476d29314f157507d505", "Wrong format: only supported version is 1", ), ( "swh:1:foo:fed8bc9d7a6bcf6db04f476d29314f157507d505", "Wrong input: Supported types are", ), ( "swh:1:dir:0b6959356d30f1a4e9b7f6bca59b9a336464c03d;invalid;malformed", "Contextual data is badly formatted, form key=val expected", ), ("swh:1:snp:gh6959356d30f1a4e9b7f6bca59b9a336464c03d", "Unexpected characters"), ("swh:1:snp:foo", "Unexpected characters"), ], ) def test_parse_swhid_parsing_error(swhid, expected_error): with pytest.raises(ValidationError, match=expected_error): > identifiers.parse_swhid(swhid) .tox/py3/lib/python3.7/site-packages/swh/model/tests/test_identifiers.py:1078: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ swhid = 'swh:1:' def parse_swhid(swhid: str) -> SWHID: """Parse :ref:`persistent-identifiers`. Args: swhid (str): A persistent identifier Raises: swh.model.exceptions.ValidationError: in case of: * missing mandatory values (4) * invalid namespace supplied * invalid version supplied * invalid type supplied * missing hash * invalid hash identifier supplied Returns: a named tuple holding the parsing result """ # <swhid>;<contextual-information> swhid_parts = swhid.split(SWHID_CTXT_SEP) swhid_data = swhid_parts.pop(0).split(":") if len(swhid_data) != 4: raise ValidationError( """Wrong format: The supported format should be: <identifier_core> ::= "swh" ":" <scheme_version> ":" <object_type> ":" <object_id> ; <scheme_version> ::= "1" ; <object_type> ::= "snp" (* snapshot *) | "rel" (* release *) | "rev" (* revision *) | "dir" (* directory *) | "cnt" (* content *) ; <object_id> ::= 40 * <hex_digit> ; (* intrinsic object id, as hex-encoded SHA1 *) <dec_digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; <hex_digit> ::= <dec_digit> | "a" | "b" | "c" | "d" | "e" | "f" ; > """ ) E swh.model.exceptions.ValidationError: ['Wrong format: The supported format should be:\n <identifier_core> ::= "swh" ":" <scheme_version> ":" <object_type> ":" <object_id> ;\n <scheme_version> ::= "1" ;\n <object_type> ::=\n "snp" (* snapshot *)\n | "rel" (* release *)\n | "rev" (* revision *)\n | "dir" (* directory *)\n | "cnt" (* content *)\n ;\n <object_id> ::= 40 * <hex_digit> ; (* intrinsic object id, as hex-encoded SHA1 *)\n <dec_digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;\n <hex_digit> ::= <dec_digit> | "a" | "b" | "c" | "d" | "e" | "f" ;\n'] .tox/py3/lib/python3.7/site-packages/swh/model/identifiers.py:837: ValidationError During handling of the above exception, another exception occurred: swhid = 'swh:1:' expected_error = 'Wrong format: There should be 4 mandatory values' @pytest.mark.parametrize( "swhid,expected_error", [ ("swh:1:cnt", "Wrong format: There should be 4 mandatory values"), ("swh:1:", "Wrong format: There should be 4 mandatory values"), ("swh:", "Wrong format: There should be 4 mandatory values"), ("swh:1:cnt:", "Wrong format: Identifier should be present"), ( "foo:1:cnt:abc8bc9d7a6bcf6db04f476d29314f157507d505", "Wrong format: only supported namespace is 'swh'", ), ( "swh:2:dir:def8bc9d7a6bcf6db04f476d29314f157507d505", "Wrong format: only supported version is 1", ), ( "swh:1:foo:fed8bc9d7a6bcf6db04f476d29314f157507d505", "Wrong input: Supported types are", ), ( "swh:1:dir:0b6959356d30f1a4e9b7f6bca59b9a336464c03d;invalid;malformed", "Contextual data is badly formatted, form key=val expected", ), ("swh:1:snp:gh6959356d30f1a4e9b7f6bca59b9a336464c03d", "Unexpected characters"), ("swh:1:snp:foo", "Unexpected characters"), ], ) def test_parse_swhid_parsing_error(swhid, expected_error): with pytest.raises(ValidationError, match=expected_error): > identifiers.parse_swhid(swhid) E AssertionError: Regex pattern 'Wrong format: There should be 4 mandatory values' does not match '[\'Wrong format: The supported format should be:\\n <identifier_core> ::= "swh" ":" <scheme_version> ":" <object_type> ":" <object_id> ;\\n <scheme_version> ::= "1" ;\\n <object_type> ::=\\n "snp" (* snapshot *)\\n | "rel" (* release *)\\n | "rev" (* revision *)\\n | "dir" (* directory *)\\n | "cnt" (* content *)\\n ;\\n <object_id> ::= 40 * <hex_digit> ; (* intrinsic object id, as hex-encoded SHA1 *)\\n <dec_digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;\\n <hex_digit> ::= <dec_digit> | "a" | "b" | "c" | "d" | "e" | "f" ;\\n\']'. .tox/py3/lib/python3.7/site-packages/swh/model/tests/test_identifiers.py:1078: AssertionError