Skip to content

Commit 7bf3c67

Browse files
committed
Improved configuration options for shed-tools tool test functionality, fixes.
1 parent 98a13c9 commit 7bf3c67

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

ephemeris/shed_tools.py

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,16 @@ def _parser():
293293
install_resolver_dependencies=False,
294294
force_latest_revision=False,
295295
test=False,
296+
test_user_api_key=None,
297+
test_user="ephemeris@galaxyproject.org",
296298
test_json="tool_test_output.json",
297299
test_existing=False,
298300
)
299301
install_command_parser = subparsers.add_parser(
300302
"install",
301303
help="This installs tools in Galaxy from the Tool Shed."
302304
"Use shed-tools install --help for more information",
303-
parents=[common_arguments],
304-
)
305+
parents=[common_arguments])
305306
update_command_parser = subparsers.add_parser(
306307
"update",
307308
help="This updates all tools in Galaxy to the latest revision. "
@@ -312,7 +313,7 @@ def _parser():
312313
"test",
313314
help="This tests the supplied list of tools in Galaxy. "
314315
"Use shed-tools test --help for more information",
315-
)
316+
parents=[common_arguments])
316317

317318
for command_parser in [install_command_parser, test_command_parser]:
318319
command_parser.add_argument(
@@ -399,6 +400,22 @@ def _parser():
399400
help="If testing tools, record tool test output to specified file. "
400401
"This file can be turned into reports with ``planemo test_reports <output.json>``."
401402
)
403+
command_parser.add_argument(
404+
"--test_user_api_key",
405+
dest="test_json",
406+
help="If testing tools, a user is needed to execute the tests. "
407+
"This can be different the --api_key which is assumed to be an admin key. "
408+
"If --api_key is a valid user (e.g. it is not a master API key) this does "
409+
"not need to be specified and --api_key will be reused."
410+
)
411+
command_parser.add_argument(
412+
"--test_user",
413+
dest="test_json",
414+
help="If testing tools, a user is needed to execute the tests. "
415+
"If --api_key is a master api key (i.e. not tied to a real user) and "
416+
"--test_user_api_key isn't specified, this user email will be used. This "
417+
"user will be created if needed."
418+
)
402419

403420
# Same test_json as above but language modified for test instead of install/update.
404421
test_command_parser.add_argument(
@@ -408,6 +425,23 @@ def _parser():
408425
"This file can be turned into reports with ``planemo test_reports <output.json>``."
409426
)
410427

428+
test_command_parser.add_argument(
429+
"--test_user_api_key",
430+
dest="test_user_api_key",
431+
help="A user is needed to execute the tests. "
432+
"This can be different the --api_key which is assumed to be an admin key. "
433+
"If --api_key is a valid user (e.g. it is not a master API key) this does "
434+
"not need to be specified and --api_key will be reused."
435+
)
436+
test_command_parser.add_argument(
437+
"--test_user",
438+
dest="test_user",
439+
help="A user is needed to execute the tests. "
440+
"If --api_key is a master api key (i.e. not tied to a real user) and "
441+
"--test_user_api_key isn't specified, this user email will be used. This "
442+
"user will be created if needed."
443+
)
444+
411445
update_command_parser.set_defaults(
412446
action="update",
413447
)
@@ -577,6 +611,8 @@ def get_install_repository_manager(options):
577611
default_install_resolver_dependencies=install_resolver_dependencies,
578612
force_latest_revision=force_latest_revision,
579613
test=options.test,
614+
test_user=options.test_user,
615+
test_user_api_key=options.test_user_api_key,
580616
test_existing=options.test_existing,
581617
test_json=options.test_json,
582618
)
@@ -593,6 +629,8 @@ def __init__(self,
593629
require_tool_panel_info=True,
594630
force_latest_revision=False,
595631
test=False,
632+
test_user_api_key=None,
633+
test_user="ephemeris@galaxyproject.org",
596634
test_existing=False,
597635
test_json="tool_test_output.json"):
598636
self.repositories = repositories
@@ -609,6 +647,8 @@ def __init__(self,
609647
self.test = test
610648
self.test_existing = test_existing
611649
self.test_json = test_json
650+
self.test_user_api_key = test_user_api_key
651+
self.test_user = test_user
612652
self.tests_passed = []
613653
self.test_exceptions = []
614654

@@ -756,17 +796,24 @@ def test_repositories(self, target_repositories=None):
756796
)
757797
log.info("Failed tool tests ({0}): {1}".format(
758798
len(self.test_exceptions),
759-
[t[0] for t in self.errored_repositories])
799+
[t[0] for t in self.test_exceptions])
760800
)
761801
log.info("Total tool test time: {0}".format(dt.datetime.now() - tool_test_start))
762802

763803
def _test_tool(self, tool):
804+
test_user_api_key = self.test_user_api_key
805+
if test_user_api_key is None:
806+
whoami = self.gi.make_get_request(self.gi.url + "/whoami").json()
807+
if whoami is not None:
808+
test_user_api_key = self.gi.key
764809
galaxy_interactor_kwds = {
765810
"galaxy_url": re.sub('/api', '', self.gi.url),
766811
"master_api_key": self.gi.key,
767812
"api_key": None, # TODO
768813
"keep_outputs_dir": '',
769814
}
815+
if test_user_api_key is None:
816+
galaxy_interactor_kwds["test_user"] = self.test_user
770817
galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
771818
tool_id = tool["id"]
772819
tool_version = tool["version"]

0 commit comments

Comments
 (0)