Skip to content
Snippets Groups Projects
Commit 161295cc authored by Jenkins for Software Heritage's avatar Jenkins for Software Heritage
Browse files

New upstream version 0.0.3

parents 8f651d9d f21145a9
No related branches found
Tags debian/upstream/0.0.3
No related merge requests found
Metadata-Version: 2.1
Name: swh.scrubber
Version: 0.0.2
Version: 0.0.3
Summary: Software Heritage Datastore Scrubber
Home-page: https://forge.softwareheritage.org/diffusion/swh-scrubber
Author: Software Heritage developers
......
......@@ -2,3 +2,4 @@
# should match https://pypi.python.org/pypi names. For the full spec or
# dependency lines, see https://pip.readthedocs.org/en/1.1/requirements.html
dulwich
Metadata-Version: 2.1
Name: swh.scrubber
Version: 0.0.2
Version: 0.0.3
Summary: Software Heritage Datastore Scrubber
Home-page: https://forge.softwareheritage.org/diffusion/swh-scrubber
Author: Software Heritage developers
......
......@@ -48,6 +48,7 @@ swh/scrubber/tests/__init__.py
swh/scrubber/tests/conftest.py
swh/scrubber/tests/test_cli.py
swh/scrubber/tests/test_fixer.py
swh/scrubber/tests/test_init.py
swh/scrubber/tests/test_journal_kafka.py
swh/scrubber/tests/test_origin_locator.py
swh/scrubber/tests/test_storage_postgresql.py
\ No newline at end of file
dulwich
swh.core[http]>=0.3
swh.loader.git>=1.4.0
swh.model>=5.0.0
......
......@@ -8,14 +8,16 @@ from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .db import ScrubberDb
from swh.scrubber.db import ScrubberDb
def get_scrubber_db(cls: str, **kwargs) -> ScrubberDb:
if cls != "local":
raise ValueError(f"Unknown scrubber db class '{cls}', use 'local' instead.")
if cls not in ("local", "postgresql"):
raise ValueError(
f"Unknown scrubber db class '{cls}', use 'postgresql' instead."
)
from .db import ScrubberDb
from swh.scrubber.db import ScrubberDb
return ScrubberDb.connect(kwargs.pop("db"), **kwargs)
......
......@@ -45,7 +45,7 @@ class FixedObject:
class ScrubberDb(BaseDb):
current_version = 1
current_version = 2
@functools.lru_cache(1000)
def datastore_get_or_add(self, datastore: Datastore) -> int:
......
......@@ -25,7 +25,7 @@ def invoke(
runner = CliRunner()
config = {
"scrubber_db": {"cls": "local", "db": scrubber_db.conn.dsn},
"scrubber_db": {"cls": "postgresql", "db": scrubber_db.conn.dsn},
"graph": {"url": "http://graph.example.org:5009/"},
}
if storage:
......@@ -72,7 +72,7 @@ def test_check_storage(mocker, scrubber_db, swh_storage):
assert result.exit_code == 0, result.output
assert result.output == ""
get_scrubber_db.assert_called_once_with(cls="local", db=scrubber_db.conn.dsn)
get_scrubber_db.assert_called_once_with(cls="postgresql", db=scrubber_db.conn.dsn)
StorageChecker.assert_called_once_with(
db=scrubber_db,
storage=StorageChecker.mock_calls[0][2]["storage"],
......@@ -103,7 +103,7 @@ def test_check_journal(
assert result.exit_code == 0, result.output
assert result.output == ""
get_scrubber_db.assert_called_once_with(cls="local", db=scrubber_db.conn.dsn)
get_scrubber_db.assert_called_once_with(cls="postgresql", db=scrubber_db.conn.dsn)
JournalChecker.assert_called_once_with(
db=scrubber_db,
journal_client={
......@@ -129,7 +129,7 @@ def test_locate_origins(mocker, scrubber_db, swh_storage):
assert result.exit_code == 0, result.output
assert result.output == ""
get_scrubber_db.assert_called_once_with(cls="local", db=scrubber_db.conn.dsn)
get_scrubber_db.assert_called_once_with(cls="postgresql", db=scrubber_db.conn.dsn)
OriginLocator.assert_called_once_with(
db=scrubber_db,
storage=OriginLocator.mock_calls[0][2]["storage"],
......@@ -150,7 +150,7 @@ def test_fix_objects(mocker, scrubber_db):
assert result.exit_code == 0, result.output
assert result.output == ""
get_scrubber_db.assert_called_once_with(cls="local", db=scrubber_db.conn.dsn)
get_scrubber_db.assert_called_once_with(cls="postgresql", db=scrubber_db.conn.dsn)
Fixer.assert_called_once_with(
db=scrubber_db,
start_object=CoreSWHID.from_string("swh:1:cnt:" + "00" * 20),
......
# Copyright (C) 2020-2022 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 typing import Any
import pytest
from swh.scrubber import get_scrubber_db
@pytest.mark.parametrize("clz", ["local", "postgresql"])
def test_get_scrubber_db(mocker, clz):
mock_scrubber = mocker.patch("swh.scrubber.db.ScrubberDb")
def test_connect(db_str: str, **kwargs) -> Any:
return "connection-result"
mock_scrubber.connect.side_effect = test_connect
actual_result = get_scrubber_db(clz, db="service=scrubber-db")
assert mock_scrubber.connect.called is True
assert actual_result == "connection-result"
@pytest.mark.parametrize("clz", ["something", "anything"])
def test_get_scrubber_db_raise(clz):
assert clz not in ["local", "postgresql"]
with pytest.raises(ValueError, match="Unknown"):
get_scrubber_db(clz, db="service=scrubber-db")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment