Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show All 18 Lines | |||||
from swh.model.from_disk import DentryPerms | from swh.model.from_disk import DentryPerms | ||||
from swh.model.hashutil import MultiHash, hash_to_bytes | from swh.model.hashutil import MultiHash, hash_to_bytes | ||||
import swh.model.hypothesis_strategies as strategies | import swh.model.hypothesis_strategies as strategies | ||||
import swh.model.model | import swh.model.model | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
BaseModel, | BaseModel, | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
DirectoryEntry, | |||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
MissingData, | MissingData, | ||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
OriginVisitStatus, | OriginVisitStatus, | ||||
Person, | Person, | ||||
▲ Show 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | |||||
def test_skipped_content_naive_datetime(): | def test_skipped_content_naive_datetime(): | ||||
c = SkippedContent.from_data(b"foo", reason="reason") | c = SkippedContent.from_data(b"foo", reason="reason") | ||||
with pytest.raises(ValueError, match="must be a timezone-aware datetime"): | with pytest.raises(ValueError, match="must be a timezone-aware datetime"): | ||||
SkippedContent( | SkippedContent( | ||||
**c.to_dict(), ctime=datetime.datetime.now(), | **c.to_dict(), ctime=datetime.datetime.now(), | ||||
) | ) | ||||
# Directory | |||||
def test_directory_entry_name_validation(): | |||||
with pytest.raises(ValueError, match="valid directory entry name."): | |||||
DirectoryEntry(name=b"foo/", type="dir", target=b"\x00" * 20, perms=0), | |||||
def test_directory_duplicate_entry_name(): | |||||
entries = ( | |||||
DirectoryEntry(name=b"foo", type="file", target=b"\x00" * 20, perms=0), | |||||
DirectoryEntry(name=b"foo", type="dir", target=b"\x01" * 20, perms=1), | |||||
ardumont: I have no idea whether this is this true for all filesystems. | |||||
Done Inline Actionswhat is? vlorentz: what is? | |||||
Not Done Inline Actionswhat you are tested here, the entries with the same name foo as file and dir. ardumont: what you are tested here, the entries with the same name foo as file and dir. | |||||
Done Inline ActionsAh, maybe. Anyway, this isn't tested at all in SWH, and the Cassandra schema doesn't support it. vlorentz: Ah, maybe. Anyway, this isn't tested at all in SWH, and the Cassandra schema doesn't support it. | |||||
) | |||||
with pytest.raises(ValueError, match="duplicated entry name"): | |||||
Directory(entries=entries) | |||||
entries = ( | |||||
DirectoryEntry(name=b"foo", type="file", target=b"\x00" * 20, perms=0), | |||||
DirectoryEntry(name=b"foo", type="file", target=b"\x00" * 20, perms=0), | |||||
) | |||||
with pytest.raises(ValueError, match="duplicated entry name"): | |||||
Directory(entries=entries) | |||||
# Revision | # Revision | ||||
def test_revision_extra_headers_no_headers(): | def test_revision_extra_headers_no_headers(): | ||||
rev_dict = revision_example.copy() | rev_dict = revision_example.copy() | ||||
rev_dict.pop("id") | rev_dict.pop("id") | ||||
rev = Revision.from_dict(rev_dict) | rev = Revision.from_dict(rev_dict) | ||||
rev_dict = attr.asdict(rev, recurse=False) | rev_dict = attr.asdict(rev, recurse=False) | ||||
▲ Show 20 Lines • Show All 545 Lines • Show Last 20 Lines |
I have no idea whether this is this true for all filesystems.