From 66b0fb1b60aeb58ed1effc3eedd109db3c838785 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Fri, 12 Aug 2022 21:25:46 -0700 Subject: [PATCH] Add return code to test command --- server/intake/cli.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/server/intake/cli.py b/server/intake/cli.py index 3a1d5d2..05af4c7 100644 --- a/server/intake/cli.py +++ b/server/intake/cli.py @@ -16,6 +16,7 @@ def command_test(args): nargs="+", help="Providers to test.", metavar="name", + dest="providers", default=[]) parser.add_argument("--path", nargs="+", @@ -25,37 +26,44 @@ def command_test(args): default=[]) args = parser.parse_args(args) + ret = 0 + search_path = args.path - if args.provider: - print("INTAKEPATH:") - for path in search_path: - print(f" {path}") - for provider_name in args.provider: + print("INTAKEPATH:") + for path in search_path: + print(f" {path}") + for provider_name in args.providers: print(f"Checking provider {provider_name}") provider = load_provider(search_path, provider_name) if not provider: print(" x Not found") + ret = 1 continue # Settings class if not hasattr(provider, "Settings"): print(" x Missing Settings class") + ret = 1 else: settings = getattr(provider, "Settings") if not issubclass(settings, BaseSettings): print(" x Settings class does not inherit from intake.BaseSettings") + ret = 1 else: print(" o Settings") # update function if not hasattr(provider, "Settings"): print(" x Missing update(config, state)") + ret = 1 else: update = getattr(provider, "update") if not callable(update): print(" x update is not callable") + ret = 1 else: update_sig = inspect.signature(update) if list(update_sig.parameters) != ["config", "state"]: print(" x update does not have signature (config, state)") + ret = 1 else: print(" o update") # on-create hook @@ -63,10 +71,12 @@ def command_test(args): on_create = getattr(provider, "on_create") if not callable(on_create): print(" x on_create is not callable") + ret = 1 else: create_sig = inspect.signature(on_create) if list(create_sig.parameters) != ["config", "state", "item"]: print(" x on_create does not have signature (config, state, item)") + ret = 1 else: print(" o on_create") # on-delete hook @@ -74,10 +84,12 @@ def command_test(args): on_delete = getattr(provider, "on_delete") if not callable(on_delete): print(" x on_delete is not callable") + ret = 1 else: delete_sig = inspect.signature(on_delete) if list(delete_sig.parameters) != ["config", "state", "item"]: print(" x on_delete does not have signature (config, state, item)") + ret = 1 else: print(" o on_delete") # actions @@ -86,13 +98,16 @@ def command_test(args): action = getattr(provider, action_name) if not callable(action): print(f" x {action_name} is not callable") + ret = 1 else: action_sig = inspect.signature(action) if list(action_sig.parameters) != ["config", "state", "item"]: print(f" x {action_name} does not have signature (config, state, item)") + ret = 1 else: print(f" o {action_name}") print("Done") + return ret def command_help(args):