Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/deposit/tests/test_deposit.py
Show All 13 Lines | |||||
from swh.loader.package.loader import now | from swh.loader.package.loader import now | ||||
from swh.loader.tests import assert_last_visit_matches, check_snapshot, get_stats | from swh.loader.tests import assert_last_visit_matches, check_snapshot, get_stats | ||||
from swh.model.hashutil import hash_to_bytes, hash_to_hex | from swh.model.hashutil import hash_to_bytes, hash_to_hex | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
Origin, | Origin, | ||||
Person, | |||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Revision, | |||||
RevisionType, | |||||
Snapshot, | Snapshot, | ||||
SnapshotBranch, | SnapshotBranch, | ||||
TargetType, | TargetType, | ||||
Timestamp, | |||||
TimestampWithTimezone, | |||||
) | ) | ||||
from swh.model.swhids import CoreSWHID, ExtendedObjectType, ExtendedSWHID, ObjectType | from swh.model.swhids import CoreSWHID, ExtendedObjectType, ExtendedSWHID, ObjectType | ||||
DEPOSIT_URL = "https://deposit.softwareheritage.org/1/private" | DEPOSIT_URL = "https://deposit.softwareheritage.org/1/private" | ||||
@pytest.fixture | @pytest.fixture | ||||
def requests_mock_datadir(requests_mock_datadir): | def requests_mock_datadir(requests_mock_datadir): | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | expected_snapshot = Snapshot( | ||||
b"HEAD": SnapshotBranch( | b"HEAD": SnapshotBranch( | ||||
target=revision_id, target_type=TargetType.REVISION, | target=revision_id, target_type=TargetType.REVISION, | ||||
), | ), | ||||
}, | }, | ||||
) | ) | ||||
check_snapshot(expected_snapshot, storage=loader.storage) | check_snapshot(expected_snapshot, storage=loader.storage) | ||||
revision = loader.storage.revision_get([revision_id])[0] | revision = loader.storage.revision_get([revision_id])[0] | ||||
date = TimestampWithTimezone( | assert revision is not None | ||||
timestamp=Timestamp(seconds=1507389428, microseconds=0), | |||||
offset=0, | |||||
negative_utc=False, | |||||
) | |||||
person = Person( | |||||
fullname=b"Software Heritage", | |||||
name=b"Software Heritage", | |||||
email=b"robot@softwareheritage.org", | |||||
) | |||||
assert revision == Revision( | |||||
id=revision_id, | |||||
message=b"hal: Deposit 666 in collection hal", | |||||
author=person, | |||||
committer=person, | |||||
date=date, | |||||
committer_date=date, | |||||
type=RevisionType.TAR, | |||||
directory=b"\xfd-\xf1-\xc5SL\x1d\xa1\xe9\x18\x0b\x91Q\x02\xfbo`\x1d\x19", | |||||
synthetic=True, | |||||
metadata=None, | |||||
parents=(), | |||||
extra_headers=(), | |||||
) | |||||
# check metadata | # check metadata | ||||
fetcher = MetadataFetcher(name="swh-deposit", version="0.0.1",) | fetcher = MetadataFetcher(name="swh-deposit", version="0.0.1",) | ||||
authority = MetadataAuthority( | authority = MetadataAuthority( | ||||
type=MetadataAuthorityType.DEPOSIT_CLIENT, | type=MetadataAuthorityType.DEPOSIT_CLIENT, | ||||
url="https://hal-test.archives-ouvertes.fr/", | url="https://hal-test.archives-ouvertes.fr/", | ||||
▲ Show 20 Lines • Show All 243 Lines • Show Last 20 Lines |