Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_backfill.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 functools | import functools | ||||
import logging | import logging | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
import pytest | import pytest | ||||
from swh.journal.client import JournalClient | from swh.journal.client import JournalClient | ||||
from swh.journal.tests.journal_data import TEST_OBJECTS | from swh.model.tests.swh_model_data import TEST_OBJECTS | ||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
from swh.storage.backfill import ( | from swh.storage.backfill import ( | ||||
PARTITION_KEY, | PARTITION_KEY, | ||||
JournalBackfiller, | JournalBackfiller, | ||||
byte_ranges, | byte_ranges, | ||||
compute_query, | compute_query, | ||||
raw_extrinsic_metadata_target_ranges, | raw_extrinsic_metadata_target_ranges, | ||||
) | ) | ||||
Show All 32 Lines | def test_config_ko_unknown_object_type(): | ||||
""" | """ | ||||
backfiller = JournalBackfiller(TEST_CONFIG) | backfiller = JournalBackfiller(TEST_CONFIG) | ||||
with pytest.raises(ValueError) as e: | with pytest.raises(ValueError) as e: | ||||
backfiller.parse_arguments("unknown-object-type", 1, 2) | backfiller.parse_arguments("unknown-object-type", 1, 2) | ||||
error = ( | error = ( | ||||
"Object type unknown-object-type is not supported. " | "Object type unknown-object-type is not supported. " | ||||
"The only possible values are %s" % (", ".join(PARTITION_KEY)) | "The only possible values are %s" % (", ".join(sorted(PARTITION_KEY))) | ||||
) | ) | ||||
assert e.value.args[0] == error | assert e.value.args[0] == error | ||||
def test_compute_query_content(): | def test_compute_query_content(): | ||||
query, where_args, column_aliases = compute_query("content", "\x000000", "\x000001") | query, where_args, column_aliases = compute_query("content", "\x000000", "\x000001") | ||||
assert where_args == ["\x000000", "\x000001"] | assert where_args == ["\x000000", "\x000001"] | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | def test_raw_extrinsic_metadata_target_ranges(): | ||||
assert bounds == sorted(bounds) | assert bounds == sorted(bounds) | ||||
RANGE_GENERATORS = { | RANGE_GENERATORS = { | ||||
"content": lambda start, end: [(None, None)], | "content": lambda start, end: [(None, None)], | ||||
"skipped_content": lambda start, end: [(None, None)], | "skipped_content": lambda start, end: [(None, None)], | ||||
"directory": lambda start, end: [(None, None)], | "directory": lambda start, end: [(None, None)], | ||||
"extid": lambda start, end: [(None, None)], | |||||
"metadata_authority": lambda start, end: [(None, None)], | "metadata_authority": lambda start, end: [(None, None)], | ||||
"metadata_fetcher": lambda start, end: [(None, None)], | "metadata_fetcher": lambda start, end: [(None, None)], | ||||
"revision": lambda start, end: [(None, None)], | "revision": lambda start, end: [(None, None)], | ||||
"release": lambda start, end: [(None, None)], | "release": lambda start, end: [(None, None)], | ||||
"snapshot": lambda start, end: [(None, None)], | "snapshot": lambda start, end: [(None, None)], | ||||
"origin": lambda start, end: [(None, 10000)], | "origin": lambda start, end: [(None, 10000)], | ||||
"origin_visit": lambda start, end: [(None, 10000)], | "origin_visit": lambda start, end: [(None, 10000)], | ||||
"origin_visit_status": lambda start, end: [(None, 10000)], | "origin_visit_status": lambda start, end: [(None, 10000)], | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |