Add return code to test command
This commit is contained in:
parent
1379e5f8a3
commit
66b0fb1b60
|
@ -16,6 +16,7 @@ def command_test(args):
|
||||||
nargs="+",
|
nargs="+",
|
||||||
help="Providers to test.",
|
help="Providers to test.",
|
||||||
metavar="name",
|
metavar="name",
|
||||||
|
dest="providers",
|
||||||
default=[])
|
default=[])
|
||||||
parser.add_argument("--path",
|
parser.add_argument("--path",
|
||||||
nargs="+",
|
nargs="+",
|
||||||
|
@ -25,37 +26,44 @@ def command_test(args):
|
||||||
default=[])
|
default=[])
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
|
ret = 0
|
||||||
|
|
||||||
search_path = args.path
|
search_path = args.path
|
||||||
if args.provider:
|
print("INTAKEPATH:")
|
||||||
print("INTAKEPATH:")
|
for path in search_path:
|
||||||
for path in search_path:
|
print(f" {path}")
|
||||||
print(f" {path}")
|
for provider_name in args.providers:
|
||||||
for provider_name in args.provider:
|
|
||||||
print(f"Checking provider {provider_name}")
|
print(f"Checking provider {provider_name}")
|
||||||
provider = load_provider(search_path, provider_name)
|
provider = load_provider(search_path, provider_name)
|
||||||
if not provider:
|
if not provider:
|
||||||
print(" x Not found")
|
print(" x Not found")
|
||||||
|
ret = 1
|
||||||
continue
|
continue
|
||||||
# Settings class
|
# Settings class
|
||||||
if not hasattr(provider, "Settings"):
|
if not hasattr(provider, "Settings"):
|
||||||
print(" x Missing Settings class")
|
print(" x Missing Settings class")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
settings = getattr(provider, "Settings")
|
settings = getattr(provider, "Settings")
|
||||||
if not issubclass(settings, BaseSettings):
|
if not issubclass(settings, BaseSettings):
|
||||||
print(" x Settings class does not inherit from intake.BaseSettings")
|
print(" x Settings class does not inherit from intake.BaseSettings")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
print(" o Settings")
|
print(" o Settings")
|
||||||
# update function
|
# update function
|
||||||
if not hasattr(provider, "Settings"):
|
if not hasattr(provider, "Settings"):
|
||||||
print(" x Missing update(config, state)")
|
print(" x Missing update(config, state)")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
update = getattr(provider, "update")
|
update = getattr(provider, "update")
|
||||||
if not callable(update):
|
if not callable(update):
|
||||||
print(" x update is not callable")
|
print(" x update is not callable")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
update_sig = inspect.signature(update)
|
update_sig = inspect.signature(update)
|
||||||
if list(update_sig.parameters) != ["config", "state"]:
|
if list(update_sig.parameters) != ["config", "state"]:
|
||||||
print(" x update does not have signature (config, state)")
|
print(" x update does not have signature (config, state)")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
print(" o update")
|
print(" o update")
|
||||||
# on-create hook
|
# on-create hook
|
||||||
|
@ -63,10 +71,12 @@ def command_test(args):
|
||||||
on_create = getattr(provider, "on_create")
|
on_create = getattr(provider, "on_create")
|
||||||
if not callable(on_create):
|
if not callable(on_create):
|
||||||
print(" x on_create is not callable")
|
print(" x on_create is not callable")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
create_sig = inspect.signature(on_create)
|
create_sig = inspect.signature(on_create)
|
||||||
if list(create_sig.parameters) != ["config", "state", "item"]:
|
if list(create_sig.parameters) != ["config", "state", "item"]:
|
||||||
print(" x on_create does not have signature (config, state, item)")
|
print(" x on_create does not have signature (config, state, item)")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
print(" o on_create")
|
print(" o on_create")
|
||||||
# on-delete hook
|
# on-delete hook
|
||||||
|
@ -74,10 +84,12 @@ def command_test(args):
|
||||||
on_delete = getattr(provider, "on_delete")
|
on_delete = getattr(provider, "on_delete")
|
||||||
if not callable(on_delete):
|
if not callable(on_delete):
|
||||||
print(" x on_delete is not callable")
|
print(" x on_delete is not callable")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
delete_sig = inspect.signature(on_delete)
|
delete_sig = inspect.signature(on_delete)
|
||||||
if list(delete_sig.parameters) != ["config", "state", "item"]:
|
if list(delete_sig.parameters) != ["config", "state", "item"]:
|
||||||
print(" x on_delete does not have signature (config, state, item)")
|
print(" x on_delete does not have signature (config, state, item)")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
print(" o on_delete")
|
print(" o on_delete")
|
||||||
# actions
|
# actions
|
||||||
|
@ -86,13 +98,16 @@ def command_test(args):
|
||||||
action = getattr(provider, action_name)
|
action = getattr(provider, action_name)
|
||||||
if not callable(action):
|
if not callable(action):
|
||||||
print(f" x {action_name} is not callable")
|
print(f" x {action_name} is not callable")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
action_sig = inspect.signature(action)
|
action_sig = inspect.signature(action)
|
||||||
if list(action_sig.parameters) != ["config", "state", "item"]:
|
if list(action_sig.parameters) != ["config", "state", "item"]:
|
||||||
print(f" x {action_name} does not have signature (config, state, item)")
|
print(f" x {action_name} does not have signature (config, state, item)")
|
||||||
|
ret = 1
|
||||||
else:
|
else:
|
||||||
print(f" o {action_name}")
|
print(f" o {action_name}")
|
||||||
print("Done")
|
print("Done")
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def command_help(args):
|
def command_help(args):
|
||||||
|
|
Loading…
Reference in New Issue