self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f7450655550>
swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f74507ddcf8>
def test_content_add_from_lazy_content(self, swh_storage):
called = False
cont = data.cont
class LazyContent(Content):
def with_data(self):
nonlocal called
called = True
return Content.from_dict({**self.to_dict(), "data": cont["data"]})
lazy_content = LazyContent.from_dict({**cont, "data": b"nope",})
insertion_start_time = datetime.datetime.now(tz=datetime.timezone.utc)
# bypass the validation proxy for now, to directly put a dict
actual_result = swh_storage.storage.content_add([lazy_content])
insertion_end_time = datetime.datetime.now(tz=datetime.timezone.utc)
assert actual_result == {
"content:add": 1,
"content:add:bytes": cont["length"],
}
assert called
assert list(swh_storage.content_get([cont["sha1"]])) == [
{"sha1": cont["sha1"], "data": cont["data"]}
]
expected_cont = data.cont
del expected_cont["data"]
journal_objects = list(swh_storage.journal_writer.journal.objects)
for (obj_type, obj) in journal_objects:
assert insertion_start_time <= obj["ctime"]
assert obj["ctime"] <= insertion_end_time
del obj["ctime"]
assert journal_objects == [("content", expected_cont)]
swh_storage.refresh_stat_counters()
> assert swh_storage.stat_counters()["content"] == 1
E assert 4 == 1
E +4
E -1
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_storage.py:223: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Apr 9 2020, 12:48 PM