Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/bzr/tests/test_loader.py
- This file was added.
# Copyright (C) 2021 The Software Heritage developers | |||||
# See the AUTHORS file at the top-level directory of this distribution | |||||
# License: GNU General Public License version 3, or any later version | |||||
# See top-level LICENSE file for more information | |||||
from pathlib import Path | |||||
import pytest | |||||
from swh.loader.bzr.loader import BazaarLoaderFromDisk | |||||
from swh.loader.tests import ( | |||||
assert_last_visit_matches, | |||||
get_stats, | |||||
prepare_repository_from_archive, | |||||
) | |||||
from swh.storage.algos.snapshot import snapshot_get_latest | |||||
@pytest.mark.parametrize("archive_name", ("hello",)) | |||||
def test_examples(swh_storage, datadir, tmp_path, archive_name): | |||||
archive_path = Path(datadir, f"{archive_name}.tgz") | |||||
repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | |||||
res = BazaarLoaderFromDisk(swh_storage, repo_url, directory=repo_url).load() | |||||
assert res == {"status": "eventful"} | |||||
assert_last_visit_matches(swh_storage, repo_url, status="full", type="bzr") | |||||
snapshot = snapshot_get_latest(swh_storage, repo_url) | |||||
expected_branches = [ | |||||
b"HEAD", | |||||
b"hello", | |||||
] | |||||
assert sorted(snapshot.branches.keys()) == expected_branches | |||||
stats = get_stats(swh_storage) | |||||
assert stats == { | |||||
"content": 2, | |||||
"directory": 2, | |||||
"origin": 1, | |||||
"origin_visit": 1, | |||||
"release": 0, | |||||
"revision": 2, | |||||
"skipped_content": 0, | |||||
"snapshot": 1, | |||||
} | |||||
assert 0 |