Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show First 20 Lines • Show All 835 Lines • ▼ Show 20 Lines | def test_content_naive_datetime(): | ||||
c = Content.from_data(b"foo") | c = Content.from_data(b"foo") | ||||
with pytest.raises(ValueError, match="must be a timezone-aware datetime"): | with pytest.raises(ValueError, match="must be a timezone-aware datetime"): | ||||
Content( | Content( | ||||
**c.to_dict(), | **c.to_dict(), | ||||
ctime=datetime.datetime.now(), | ctime=datetime.datetime.now(), | ||||
) | ) | ||||
@given(strategies.contents().filter(lambda cnt: cnt.data is not None)) | |||||
def test_content_check(content): | |||||
content.check() | |||||
content2 = attr.evolve(content, id=b"\x00" * 20) | |||||
with pytest.raises(ValueError, match="does not match recomputed hash"): | |||||
content2.check() | |||||
content2 = attr.evolve( | |||||
content, raw_manifest=swh.model.git_objects.content_git_object(content) | |||||
) | |||||
content2.check() | |||||
# SkippedContent | # SkippedContent | ||||
@given(binary(max_size=4096)) | @given(binary(max_size=4096)) | ||||
def test_skipped_content_from_data(data): | def test_skipped_content_from_data(data): | ||||
c = SkippedContent.from_data(data, reason="reason") | c = SkippedContent.from_data(data, reason="reason") | ||||
assert c.reason == "reason" | assert c.reason == "reason" | ||||
assert c.length == len(data) | assert c.length == len(data) | ||||
▲ Show 20 Lines • Show All 790 Lines • Show Last 20 Lines |