Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/maven/tests/test_maven.py
# Copyright (C) 2019-2021 The Software Heritage developers | # Copyright (C) 2019-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import datetime | |||||
import hashlib | import hashlib | ||||
import json | import json | ||||
from pathlib import Path | from pathlib import Path | ||||
import pytest | import pytest | ||||
from swh.loader.package import __version__ | from swh.loader.package import __version__ | ||||
from swh.loader.package.maven.loader import MavenLoader, MavenPackageInfo | from swh.loader.package.maven.loader import MavenLoader, MavenPackageInfo | ||||
from swh.loader.package.utils import EMPTY_AUTHOR | from swh.loader.package.utils import EMPTY_AUTHOR | ||||
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 | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Release, | Release, | ||||
Snapshot, | Snapshot, | ||||
SnapshotBranch, | SnapshotBranch, | ||||
TargetType, | TargetType, | ||||
Timestamp, | |||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
from swh.model.model import MetadataAuthority, MetadataAuthorityType, MetadataFetcher | from swh.model.model import MetadataAuthority, MetadataAuthorityType, MetadataFetcher | ||||
from swh.model.model import ObjectType as ModelObjectType | from swh.model.model import ObjectType as ModelObjectType | ||||
from swh.model.swhids import CoreSWHID, ExtendedObjectType, ExtendedSWHID, ObjectType | from swh.model.swhids import CoreSWHID, ExtendedObjectType, ExtendedSWHID, ObjectType | ||||
from swh.storage.algos.snapshot import snapshot_get_all_branches | from swh.storage.algos.snapshot import snapshot_get_all_branches | ||||
URL = "https://repo1.maven.org/maven2/" | URL = "https://repo1.maven.org/maven2/" | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | |||||
_expected_new_release_first_visit = "02e83c29ec094db581f939d2e238d0613a4f59ac" | _expected_new_release_first_visit = "02e83c29ec094db581f939d2e238d0613a4f59ac" | ||||
REL_MSG = ( | REL_MSG = ( | ||||
b"Synthetic release for archive at https://repo1.maven.org/maven2/al/aldi/" | b"Synthetic release for archive at https://repo1.maven.org/maven2/al/aldi/" | ||||
b"sprova4j/0.1.0/sprova4j-0.1.0-sources.jar\n" | b"sprova4j/0.1.0/sprova4j-0.1.0-sources.jar\n" | ||||
) | ) | ||||
REVISION_DATE = TimestampWithTimezone( | REVISION_DATE = TimestampWithTimezone.from_datetime( | ||||
timestamp=Timestamp(seconds=1626116819, microseconds=335000), | datetime.datetime(2021, 7, 12, 19, 6, 59, 335000, tzinfo=datetime.timezone.utc) | ||||
offset=0, | |||||
negative_utc=False, | |||||
) | ) | ||||
@pytest.fixture | @pytest.fixture | ||||
def data_jar_1(datadir): | def data_jar_1(datadir): | ||||
content = Path( | content = Path( | ||||
datadir, "https_maven.org", "sprova4j-0.1.0-sources.jar" | datadir, "https_maven.org", "sprova4j-0.1.0-sources.jar" | ||||
).read_bytes() | ).read_bytes() | ||||
▲ Show 20 Lines • Show All 393 Lines • Show Last 20 Lines |