def test_revision_extra_headers_in_metadata():
rev_dict = revision_example.copy()
rev_dict.pop("id")
rev = Revision.from_dict(rev_dict)
rev_dict = attr.asdict(rev, recurse=False)
rev_dict["metadata"] = {
"something": "somewhere",
"some other thing": "stranger",
}
extra_headers = (
(b"header1", b"value1"),
(b"header2", b"42"),
(b"header3", b"should I?\u0000"),
(b"header1", b"again"),
)
# check the bw-compat init hook does the job
# ie. extra_headers are given in the metadata field
rev_dict["metadata"]["extra_headers"] = extra_headers
> rev_model = Revision(**rev_dict)
.tox/py3/lib/python3.7/site-packages/swh/model/tests/test_model.py:489:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<attrs generated init swh.model.model.Revision>:28: in __init__
self.__attrs_post_init__()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Revision(message=b'Linux 4.2-rc2\n', author=Person(fullname=b'Linus Torvalds <torvalds@linux-foundation.org>', name=b'...]\xb5\xec\xb3\x1e\x9d\xe8\x08',), id=b'\xbc\x01\x95\xaa\xd0\xda\xa2\xad[\rv\xcc\xe2+\x16{\xc3CU\x90', extra_headers=())
def __attrs_post_init__(self):
super().__attrs_post_init__()
# ensure metadata is a deep copy of whatever was given, and if needed
# extract extra_headers from there
if self.metadata:
metadata = deepcopy(self.metadata)
if not self.extra_headers and "extra_headers" in metadata:
object.__setattr__(
self,
"extra_headers",
> tuplify_extra_headers(metadata.pop("extra_headers")),
)
E AttributeError: 'ImmutableDict' object has no attribute 'pop'
.tox/py3/lib/python3.7/site-packages/swh/model/model.py:483: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Jul 7 2020, 11:53 AM