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.present_contents().filter(lambda cnt: cnt.data is not None)) | |||||
def test_content_git_roundtrip(content): | |||||
assert content.data is not None | |||||
raw = swh.model.git_objects.content_git_object(content) | |||||
sha1_git = hashlib.new("sha1", raw).digest() | |||||
assert content.sha1_git == sha1_git | |||||
# 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 |