lister: Allow lister to build url out of the instance parameter
This pushes the rather elementary logic within the lister's scope. This will simplify and unify cli call between lister and scheduler clis. This will also allow to reduce erroneous operations which can happen for example in the add-forge-now. With the following, we will only have to provide the type and the instance, then everything will be scheduled properly. Refs. swh/devel/swh-lister#4693
This commit is contained in:
parent
596e8c6c40
commit
19bdeefb14
7 changed files with 100 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2019-2021 The Software Heritage developers
|
||||
# Copyright (C) 2019-2023 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
|
||||
|
@ -17,14 +17,13 @@ lister_args = {
|
|||
"api_token": "bogus",
|
||||
},
|
||||
"gitea": {
|
||||
"url": "https://try.gitea.io/api/v1/",
|
||||
"instance": "try.gitea.io",
|
||||
},
|
||||
"tuleap": {
|
||||
"url": "https://tuleap.net",
|
||||
},
|
||||
"gitlab": {
|
||||
"url": "https://gitlab.ow2.org/api/v4",
|
||||
"instance": "ow2",
|
||||
"instance": "gitlab.ow2.org",
|
||||
},
|
||||
"opam": {"url": "https://opam.ocaml.org", "instance": "opam"},
|
||||
"maven": {
|
||||
|
@ -32,7 +31,7 @@ lister_args = {
|
|||
"index_url": "http://indexes/export.fld",
|
||||
},
|
||||
"gogs": {
|
||||
"url": "https://try.gogs.io/",
|
||||
"instance": "try.gogs.io",
|
||||
"api_token": "secret",
|
||||
},
|
||||
"nixguix": {
|
||||
|
|
|
@ -24,6 +24,24 @@ class InstantiableLister(pattern.Lister[StateType, PageType]):
|
|||
return d
|
||||
|
||||
|
||||
def test_instantiation_fail_to_instantiate(swh_scheduler):
|
||||
"""Instantiation without proper url or instance will raise."""
|
||||
# While instantiating with either a url or instance is fine...
|
||||
InstantiableLister(scheduler=swh_scheduler, url="https://example.com")
|
||||
InstantiableLister(scheduler=swh_scheduler, instance="example.com")
|
||||
|
||||
# ... Instantiating will fail when:
|
||||
# - no instance nor url parameters are provided to the constructor
|
||||
with pytest.raises(ValueError, match="'url' or 'instance"):
|
||||
InstantiableLister(
|
||||
scheduler=swh_scheduler,
|
||||
)
|
||||
|
||||
# - an instance, which is not in a net location format, is provided
|
||||
with pytest.raises(ValueError, match="net location"):
|
||||
InstantiableLister(scheduler=swh_scheduler, instance="http://example.com")
|
||||
|
||||
|
||||
def test_instantiation(swh_scheduler):
|
||||
lister = InstantiableLister(
|
||||
scheduler=swh_scheduler, url="https://example.com", instance="example.com"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue