ns = 'foo', version = 1, type = 'content'
id = 'abc8bc9d7a6bcf6db04f476d29314f157507d505'
expected_error = "Wrong format: only supported namespace is 'swh'"
@pytest.mark.parametrize(
"ns,version,type,id,expected_error",
[
(
"foo",
1,
CONTENT,
"abc8bc9d7a6bcf6db04f476d29314f157507d505",
"Wrong format: only supported namespace is 'swh'",
),
(
"swh",
2,
DIRECTORY,
"def8bc9d7a6bcf6db04f476d29314f157507d505",
"Wrong format: only supported version is 1",
),
(
"swh",
1,
"foo",
"fed8bc9d7a6bcf6db04f476d29314f157507d505",
"Wrong input: Supported types are",
),
(
"swh",
1,
SNAPSHOT,
"gh6959356d30f1a4e9b7f6bca59b9a336464c03d",
"Unexpected characters",
),
],
)
def test_SWHID_class_validation_error(ns, version, type, id, expected_error):
with pytest.raises(ValidationError, match=expected_error):
SWHID(
> namespace=ns, scheme_version=version, object_type=type, object_id=id,
)
.tox/py3/lib/python3.7/site-packages/swh/model/tests/test_identifiers.py:1117:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = SWHID(namespace='foo', scheme_version=1, object_type='content', object_id='abc8bc9d7a6bcf6db04f476d29314f157507d505', metadata=ImmutableDict({}))
namespace = 'foo', scheme_version = 1, object_type = 'content'
object_id = 'abc8bc9d7a6bcf6db04f476d29314f157507d505'
metadata = ImmutableDict({})
def __init__(self, namespace=attr_dict['namespace'].default, scheme_version=attr_dict['scheme_version'].default, object_type=attr_dict['object_type'].default, object_id=attr_dict['object_id'].default, metadata=attr_dict['metadata'].default):
_setattr = _cached_setattr.__get__(self, self.__class__)
_inst_dict = self.__dict__
_inst_dict['namespace'] = namespace
_inst_dict['scheme_version'] = scheme_version
_inst_dict['object_type'] = object_type
_inst_dict['object_id'] = __attr_converter_object_id(object_id)
_inst_dict['metadata'] = __attr_converter_metadata(metadata)
if _config._run_validators is True:
> __attr_validator_namespace(self, __attr_namespace, self.namespace)
<attrs generated init swh.model.identifiers.SWHID>:10:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = SWHID(namespace='foo', scheme_version=1, object_type='content', object_id='abc8bc9d7a6bcf6db04f476d29314f157507d505', metadata=ImmutableDict({}))
attribute = Attribute(name='namespace', default='swh', validator=<function SWHID.check_namespace at 0x7fb0a89219d8>, repr=True, eq...t=True, metadata=mappingproxy({}), type=<class 'str'>, converter=None, kw_only=False, inherited=False, on_setattr=None)
value = 'foo'
@namespace.validator
def check_namespace(self, attribute, value):
if value != SWHID_NAMESPACE:
raise ValidationError(
> f"Wrong format: Supported namespace is '{SWHID_NAMESPACE}'"
)
E swh.model.exceptions.ValidationError: ["Wrong format: Supported namespace is 'swh'"]
.tox/py3/lib/python3.7/site-packages/swh/model/identifiers.py:731: ValidationError
During handling of the above exception, another exception occurred:
ns = 'foo', version = 1, type = 'content'
id = 'abc8bc9d7a6bcf6db04f476d29314f157507d505'
expected_error = "Wrong format: only supported namespace is 'swh'"
@pytest.mark.parametrize(
"ns,version,type,id,expected_error",
[
(
"foo",
1,
CONTENT,
"abc8bc9d7a6bcf6db04f476d29314f157507d505",
"Wrong format: only supported namespace is 'swh'",
),
(
"swh",
2,
DIRECTORY,
"def8bc9d7a6bcf6db04f476d29314f157507d505",
"Wrong format: only supported version is 1",
),
(
"swh",
1,
"foo",
"fed8bc9d7a6bcf6db04f476d29314f157507d505",
"Wrong input: Supported types are",
),
(
"swh",
1,
SNAPSHOT,
"gh6959356d30f1a4e9b7f6bca59b9a336464c03d",
"Unexpected characters",
),
],
)
def test_SWHID_class_validation_error(ns, version, type, id, expected_error):
with pytest.raises(ValidationError, match=expected_error):
SWHID(
> namespace=ns, scheme_version=version, object_type=type, object_id=id,
)
E AssertionError: Regex pattern "Wrong format: only supported namespace is 'swh'" does not match '["Wrong format: Supported namespace is \'swh\'"]'.
.tox/py3/lib/python3.7/site-packages/swh/model/tests/test_identifiers.py:1117: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Nov 10 2020, 6:22 PM