diff --git a/conftest.py b/conftest.py --- a/conftest.py +++ b/conftest.py @@ -7,8 +7,6 @@ # Modules that should not be loaded by --doctest-modules collect_ignore = [ - # ImportError - 'swh/scheduler/updater/ghtorrent/fake.py', # NotImplementedError: save_group is not supported by this backend. 'swh/scheduler/tests/tasks.py', # OSError: Configuration file must be defined diff --git a/swh/scheduler/cli.py b/swh/scheduler/cli.py --- a/swh/scheduler/cli.py +++ b/swh/scheduler/cli.py @@ -17,6 +17,7 @@ from . import compute_nb_tasks_from from .backend_es import SWHElasticSearchClient from . import get_scheduler, DEFAULT_CONFIG +from .cli_utils import parse_options locale.setlocale(locale.LC_ALL, '') @@ -300,8 +301,7 @@ now = arrow.utcnow() - args = [x for x in options if '=' not in x] - kw = dict(x.split('=', 1) for x in options if '=' in x) + (args, kw) = parse_options(options) task = {'type': type, 'policy': policy, 'priority': priority, diff --git a/swh/scheduler/cli_utils.py b/swh/scheduler/cli_utils.py new file mode 100644 --- /dev/null +++ b/swh/scheduler/cli_utils.py @@ -0,0 +1,21 @@ +# Copyright (C) 2019 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 + + +def parse_options(options): + """Parses options from a CLI and turns it into Python args and kwargs. + + >>> parse_options([]) + ([], {}) + >>> parse_options(['foo', 'bar']) + (['foo', 'bar'], {}) + >>> parse_options(['foo=bar']) + ([], {'foo': 'bar'}) + >>> parse_options(['foo', 'bar=baz']) + (['foo'], {'bar': 'baz'}) + """ + args = [x for x in options if '=' not in x] + kw = dict(x.split('=', 1) for x in options if '=' in x) + return (args, kw) diff --git a/swh/scheduler/updater/ghtorrent/fake.py b/swh/scheduler/updater/ghtorrent/fake.py --- a/swh/scheduler/updater/ghtorrent/fake.py +++ b/swh/scheduler/updater/ghtorrent/fake.py @@ -9,7 +9,12 @@ from arrow import utcnow from kombu import Connection -from swh.scheduler.updater.ghtorrent import RabbitMQConn, events +from swh.scheduler.updater.ghtorrent import events + + +class RabbitMQConn: + # FIXME + pass class FakeRandomOriginGenerator: