Tests: Don't trip over added toddlers

Relax some tests so that they cope with added toddlers without having to
update the relevant tests.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2020-07-08 15:49:12 +02:00
parent 92b3805fe1
commit 123df084b3
3 changed files with 19 additions and 22 deletions

View file

@ -2,17 +2,11 @@ import toddlers.plugins
def test_toddlers_plugins(): def test_toddlers_plugins():
variables = [var for var in dir(toddlers.plugins) if not var.startswith("__")] plugin_module_names = toddlers.plugins.__all__
assert sorted(variables) == sorted( assert not any(n.startswith("__") for n in plugin_module_names)
[ assert {
"debug",
"flag_ci_pr", "flag_ci_pr",
"flag_commit_build", "flag_commit_build",
"here",
"importlib",
"name",
"os",
"packager_bugzilla_sync", "packager_bugzilla_sync",
"pdc_retired_packages", "pdc_retired_packages",
] } <= set(plugin_module_names)
)

View file

@ -23,14 +23,14 @@ class TestRunningToddler:
@patch_messaging_config() @patch_messaging_config()
def test___init__(self): def test___init__(self):
runner = toddlers.runner.RunningToddler() runner = toddlers.runner.RunningToddler()
assert sorted([t.name for t in runner.toddlers]) == sorted( # Check that at least these toddlers exist (but don't fail
[ # automatically just because new ones are added).
assert {
"flag_ci_pr", "flag_ci_pr",
"flag_commit_build", "flag_commit_build",
"packager_bugzilla_sync", "packager_bugzilla_sync",
"pdc_retired_packages", "pdc_retired_packages",
] } <= {t.name for t in runner.toddlers}
)
@patch_messaging_config() @patch_messaging_config()
@patch("toddlers.runner.ToddlerBase") @patch("toddlers.runner.ToddlerBase")

View file

@ -2,8 +2,11 @@ import importlib
import os import os
__all__ = [] # fill below
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
for name in os.listdir(here): for name in os.listdir(here):
if name.endswith(".py") and not name.startswith("__"): if name.endswith(".py") and not name.startswith("__"):
name = name[:-3] name = name[:-3]
importlib.import_module(f".{name}", package=__name__) importlib.import_module(f".{name}", package=__name__)
__all__.append(name)