Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/archive/tests/test_archive.py
# Copyright (C) 2019-2022 The Software Heritage developers | # Copyright (C) 2019-2022 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 copy | import copy | ||||
import datetime | import datetime | ||||
import hashlib | import hashlib | ||||
from io import BytesIO | from io import BytesIO | ||||
from pathlib import Path | from pathlib import Path | ||||
import string | import string | ||||
from typing import Optional | |||||
import attr | import attr | ||||
import pytest | import pytest | ||||
from requests.exceptions import ContentDecodingError | from requests.exceptions import ContentDecodingError | ||||
from swh.loader.package.archive.loader import ArchiveLoader, ArchivePackageInfo | from swh.loader.package.archive.loader import ArchiveLoader, ArchivePackageInfo | ||||
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 | ||||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | def test_archive_2_visits_without_change_not_gnu(swh_storage, requests_mock_datadir): | ||||
assert len(urls) == 1 | assert len(urls) == 1 | ||||
def test_archive_extid(): | def test_archive_extid(): | ||||
"""Compute primary key should return the right identity""" | """Compute primary key should return the right identity""" | ||||
@attr.s | @attr.s | ||||
class TestPackageInfo(ArchivePackageInfo): | class TestPackageInfo(ArchivePackageInfo): | ||||
a = attr.ib() | # mandatory change since ArchivePackageinfo defines optional values | ||||
b = attr.ib() | a = attr.ib(type=Optional[str], default=None) | ||||
b = attr.ib(type=Optional[str], default=None) | |||||
metadata = GNU_ARTIFACTS[0] | metadata = GNU_ARTIFACTS[0] | ||||
p_info = TestPackageInfo( | p_info = TestPackageInfo( | ||||
raw_info={**metadata, "a": 1, "b": 2}, | raw_info={**metadata, "a": 1, "b": 2}, | ||||
a=1, | a=1, | ||||
b=2, | b=2, | ||||
**metadata, | **metadata, | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |