opam: Make the instance optional and derived from the url
This matches how it's done for all other multi instances listers. Related to T3590
This commit is contained in:
parent
b69b0b7fd6
commit
ff5e86ff48
2 changed files with 12 additions and 2 deletions
|
@ -8,7 +8,7 @@ import logging
|
|||
import os
|
||||
from subprocess import PIPE, Popen, call
|
||||
import tempfile
|
||||
from typing import Iterator
|
||||
from typing import Iterator, Optional
|
||||
|
||||
from swh.lister.pattern import StatelessLister
|
||||
from swh.scheduler.interface import SchedulerInterface
|
||||
|
@ -44,7 +44,7 @@ class OpamLister(StatelessLister[PageType]):
|
|||
self,
|
||||
scheduler: SchedulerInterface,
|
||||
url: str,
|
||||
instance: str,
|
||||
instance: Optional[str] = None,
|
||||
credentials: CredentialsType = None,
|
||||
):
|
||||
super().__init__(
|
||||
|
|
|
@ -28,12 +28,22 @@ def mock_opam(mocker):
|
|||
return mock_init, mock_open
|
||||
|
||||
|
||||
def test_lister_opam_optional_instance(swh_scheduler):
|
||||
"""Instance name should be optional and default to be built out of the netloc."""
|
||||
netloc = "opam.ocaml.org"
|
||||
instance_url = f"https://{netloc}"
|
||||
|
||||
lister = OpamLister(swh_scheduler, url=instance_url)
|
||||
assert lister.instance == netloc
|
||||
|
||||
|
||||
def test_urls(swh_scheduler, mock_opam):
|
||||
mock_init, mock_popen = mock_opam
|
||||
|
||||
instance_url = "https://opam.ocaml.org"
|
||||
|
||||
lister = OpamLister(swh_scheduler, url=instance_url, instance="opam")
|
||||
assert lister.instance == "opam"
|
||||
|
||||
# call the lister and get all listed origins urls
|
||||
stats = lister.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue