Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/tests/test_gnu.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 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 os | import os | ||||
import re | |||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.loader.package.gnu import GNULoader, get_version | from swh.loader.package.gnu import GNULoader, get_version | ||||
from swh.loader.package.tests.common import ( | from swh.loader.package.tests.common import ( | ||||
check_snapshot, check_metadata_paths | check_snapshot, check_metadata_paths | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | _expected_branches_first_visit = { | ||||
}, | }, | ||||
} | } | ||||
# hash is different then before as we changed the snapshot | # hash is different then before as we changed the snapshot | ||||
# gnu used to use `release/` (singular) instead of plural | # gnu used to use `release/` (singular) instead of plural | ||||
_expected_new_snapshot_first_visit_id = 'c419397fd912039825ebdbea378bc6283f006bf5' # noqa | _expected_new_snapshot_first_visit_id = 'c419397fd912039825ebdbea378bc6283f006bf5' # noqa | ||||
def test_visit_with_no_artifact_found(swh_config, requests_mock): | def test_visit_with_no_artifact_found(swh_config, requests_mock_datadir): | ||||
package_url = 'https://ftp.gnu.org/gnu/8sync/' | package_url = 'https://ftp.gnu.org/gnu/8sync/' | ||||
tarballs = [{ | tarballs = [{ | ||||
'time': '944729610', | 'time': '944729610', | ||||
'archive': 'https://ftp.gnu.org/gnu/8sync/8sync-0.1.0.tar.gz', | 'archive': 'https://ftp.gnu.org/gnu/8sync/8sync-unknown-0.1.0.tar.gz', | ||||
'length': 221837, | 'length': 221837, | ||||
}] | }] | ||||
loader = GNULoader(package_url, tarballs) | loader = GNULoader(package_url, tarballs) | ||||
requests_mock.get(re.compile('https://'), status_code=404) | |||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status['status'] == 'uneventful' | assert actual_load_status['status'] == 'uneventful' | ||||
stats = loader.storage.stat_counters() | stats = loader.storage.stat_counters() | ||||
assert { | assert { | ||||
'content': 0, | 'content': 0, | ||||
'directory': 0, | 'directory': 0, | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |