Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9338536
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
View Options
diff --git a/swh/lister/pytest_plugin.py b/swh/lister/pytest_plugin.py
index d58195c..3d72a74 100644
--- a/swh/lister/pytest_plugin.py
+++ b/swh/lister/pytest_plugin.py
@@ -1,51 +1,61 @@
# Copyright (C) 2019-2020 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
import logging
import pytest
from sqlalchemy import create_engine
from swh.lister import get_lister, SUPPORTED_LISTERS
from swh.lister.core.models import initialize
logger = logging.getLogger(__name__)
@pytest.fixture
def lister_db_url(postgresql_proc, postgresql):
db_url = "postgresql://{user}@{host}:{port}/{dbname}".format(
host=postgresql_proc.host,
port=postgresql_proc.port,
user="postgres",
dbname="tests",
)
logger.debug("lister db_url: %s", db_url)
return db_url
@pytest.fixture
-def swh_listers(mock_get_scheduler, lister_db_url, swh_scheduler):
+def listers_to_instantiate():
+ """Fixture to define what listers to instantiate. Because some need dedicated setup.
+
+ """
+ return set(SUPPORTED_LISTERS) - {"launchpad"}
+
+
+@pytest.fixture
+def swh_listers(
+ mock_get_scheduler, lister_db_url, swh_scheduler, listers_to_instantiate
+):
listers = {}
# Prepare schema for all listers
- for lister_name in SUPPORTED_LISTERS:
+ for lister_name in listers_to_instantiate:
lister = get_lister(lister_name, db_url=lister_db_url)
listers[lister_name] = lister
initialize(create_engine(lister_db_url), drop_tables=True)
# Add the load-archive-files expected by some listers (gnu, cran, ...)
swh_scheduler.create_task_type(
{
"type": "load-archive-files",
"description": "Load archive files.",
"backend_name": "swh.loader.package.tasks.LoadArchive",
"default_interval": "1 day",
}
)
return listers
diff --git a/swh/lister/tests/test_cli.py b/swh/lister/tests/test_cli.py
index 268dba6..95c19b2 100644
--- a/swh/lister/tests/test_cli.py
+++ b/swh/lister/tests/test_cli.py
@@ -1,68 +1,66 @@
# Copyright (C) 2019-2020 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
import pytest
from swh.lister.core.lister_base import ListerBase
-from swh.lister.cli import get_lister, SUPPORTED_LISTERS
+from swh.lister.cli import get_lister
from .test_utils import init_db
def test_get_lister_wrong_input():
"""Unsupported lister should raise"""
with pytest.raises(ValueError) as e:
get_lister("unknown", "db-url")
assert "Invalid lister" in str(e.value)
-def test_get_lister(mock_get_scheduler):
+def test_get_lister(mock_get_scheduler, listers_to_instantiate):
"""Instantiating a supported lister should be ok
"""
db_url = init_db().url()
- # launchpad lister need particular setup so exclude from the checks
- listers_to_check = set(SUPPORTED_LISTERS) | {"launchpad"}
- for lister_name in listers_to_check:
+ for lister_name in listers_to_instantiate:
lst = get_lister(lister_name, db_url)
assert isinstance(lst, ListerBase)
def test_get_lister_override():
"""Overriding the lister configuration should populate its config
"""
db_url = init_db().url()
listers = {
"gitlab": "https://other.gitlab.uni/api/v4/",
"phabricator": "https://somewhere.org/api/diffusion.repository.search",
"cgit": "https://some.where/cgit",
}
# check the override ends up defined in the lister
for lister_name, url in listers.items():
lst = get_lister(
lister_name,
db_url,
**{"url": url, "priority": "high", "policy": "oneshot",},
)
assert lst.url == url
assert lst.config["priority"] == "high"
assert lst.config["policy"] == "oneshot"
# check the default urls are used and not the override (since it's not
# passed)
for lister_name, url in listers.items():
lst = get_lister(lister_name, db_url)
# no override so this does not end up in lister's configuration
assert "url" not in lst.config
assert "priority" not in lst.config
assert "oneshot" not in lst.config
assert lst.url == lst.DEFAULT_URL
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jul 4 2025, 8:54 AM (6 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3273800
Attached To
rDLS Listers
Event Timeline
Log In to Comment