self = <swh.storage.tests.test_api_client.TestStorage object at 0x7fd807f9b2e8>
swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7fd808173fd0>
sample_data_model = {'content': [Content(sha1=b'4\x972t\xcc\xefj\xb4\xdf\xaa\xf8e\x99y/\xa9\xc3\xfeF\x89', sha1_git=b'\xd8\x1c\xc0q\x0e\xb...M\x804\xfa\xec\x9e\xed\xc3\x96\xbe')], 'origin': [Origin(url='file:///dev/null'), Origin(url='file:///dev/zero')], ...}
def test_content_add_from_lazy_content(self, swh_storage, sample_data_model):
cont = sample_data_model["content"][0]
lazy_content = LazyContent.from_dict(cont.to_dict())
insertion_start_time = now()
# bypass the validation proxy for now, to directly put a dict
actual_result = swh_storage.storage.content_add([lazy_content])
insertion_end_time = now()
assert actual_result == {
"content:add": 1,
"content:add:bytes": cont.length,
}
# the fact that we retrieve the content object from the storage with
# the correct 'data' field ensures it has been 'called'
assert list(swh_storage.content_get([cont.sha1])) == [
{"sha1": cont.sha1, "data": cont.data}
]
expected_cont = attr.evolve(lazy_content, data=None)
contents = [
obj
for (obj_type, obj) in swh_storage.journal_writer.journal.objects
if obj_type == "content"
]
assert len(contents) == 1
for obj in contents:
assert insertion_start_time <= obj.ctime
assert obj.ctime <= insertion_end_time
> assert obj == expected_cont
E assert Content(sha1=...timezone.utc)) == LazyContent(s...e, ctime=None)
E +Content(sha1=b'4\x972t\xcc\xefj\xb4\xdf\xaa\xf8e\x99y/\xa9\xc3\xfeF\x89', sha1_git=b'\xd8\x1c\xc0q\x0e\xb6\xcf\x9e\xfd[\x92\n\x84S\xe1\xe0qW\xb6\xcd', sha256=b'g6P\xf96\xcb;\n/\x93\xce\t\xd8\x1b\xe1\x07H\xb1\xb2\x03\xc1\x9e\x81v\xb4\xee\xfc\x19d\xa0\xcf:', blake2s256=b"\xd5\xfe\x199We'\xe4,\xfdv\xa9EZ$2\xfe\x7fVf\x95dW}\xd9<B\x80\xe7mf\x1d", length=3, status='visible', data=None, ctime=datetime.datetime(2020, 7, 17, 15, 2, 6, 423885, tzinfo=datetime.timezone.utc))
E -LazyContent(sha1=b'4\x972t\xcc\xefj\xb4\xdf\xaa\xf8e\x99y/\xa9\xc3\xfeF\x89', sha1_git=b'\xd8\x1c\xc0q\x0e...
E
E ...Full output truncated (1 line hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_storage.py:253: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jul 17 2020, 5:06 PM