Example #1
0
 def setUp(self) -> None:
     self.history_id = os.environ.get('GALAXY_TEST_HISTORY_ID', None)
     self.host, self.port, self.url = target_url_parts()
     server_wrapper = self._test_driver and self._test_driver.server_wrappers[0]
     if server_wrapper:
         self.host = server_wrapper.host
         self.port = server_wrapper.port
         self.url = f"http://{self.host}:{self.port}{server_wrapper.prefix.rstrip('/')}/"
     self.test_data_resolver = TestDataResolver()
     self.keepOutdir = setup_keep_outdir()
Example #2
0
 def run_tool_test(self, tool_id, index=0, resource_parameters=None, **kwd):
     if resource_parameters is None:
         resource_parameters = {}
     host, port, url = target_url_parts()
     galaxy_interactor_kwds = {
         "galaxy_url": url,
         "master_api_key": get_admin_api_key(),
         "api_key": get_user_api_key(),
         "keep_outputs_dir": None,
     }
     galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)
     verify_tool(tool_id=tool_id,
                 test_index=index,
                 galaxy_interactor=galaxy_interactor,
                 resource_parameters=resource_parameters,
                 **kwd)
Example #3
0
 def setUp(self):
     self.history_id = os.environ.get('GALAXY_TEST_HISTORY_ID', None)
     self.host, self.port, self.url = target_url_parts()
     self.test_data_resolver = TestDataResolver()
     self.keepOutdir = setup_keep_outdir()
Example #4
0
def build_tests(app=None,
                testing_shed_tools=False,
                master_api_key=None,
                user_api_key=None,
                name_prefix="TestForTool_",
                baseclass=ToolTestCase,
                create_admin=False,
                user_email=None,
                G=None,
                contains=None):
    """
    If the module level variable `toolbox` is set, generate `ToolTestCase`
    classes for all of its tests and put them into this modules globals() so
    they can be discovered by nose.
    """
    # galaxy_interactor = None
    # if app is None:
    host, port, url = target_url_parts()
    keep_outputs_dir = setup_keep_outdir()

    galaxy_interactor_kwds = {
        "galaxy_url": url,
        "master_api_key": master_api_key,
        "api_key": user_api_key,
        "keep_outputs_dir": keep_outputs_dir,
        "user_api_key_is_admin_key": True,
    }
    if create_admin and not user_api_key:
        galaxy_interactor_kwds['test_user'] = user_email
    galaxy_interactor = GalaxyInteractorApi(**galaxy_interactor_kwds)

    if not G:
        # Push all the toolbox tests to module level
        G = globals()

    # Eliminate all previous tests from G.
    for key in G.copy().keys():
        if key.startswith('TestForTool_'):
            del G[key]

    tests_summary = galaxy_interactor.get_tests_summary()
    for tool_id, tool_summary in tests_summary.items():
        # Create a new subclass of ToolTestCase, dynamically adding methods
        # named test_tool_XXX that run each test defined in the tool config.
        if contains and contains not in tool_id:
            continue
        name = name_prefix + tool_id.replace(' ', '_')
        baseclasses = (baseclass, )
        namespace = dict()

        all_versions_test_count = 0

        for tool_version, version_summary in tool_summary.items():
            count = version_summary["count"]
            for i in range(count):
                test_function_name = 'test_tool_%06d' % all_versions_test_count

                def make_test_method(tool_version, test_index):
                    def test_tool(self):
                        self.do_it(tool_version=tool_version,
                                   test_index=test_index)

                    test_tool.__name__ = test_function_name

                    return test_tool

                test_method = make_test_method(tool_version, i)
                test_method.__doc__ = "( %s ) > Test-%d" % (
                    tool_id, all_versions_test_count + 1)
                namespace[test_function_name] = test_method
                namespace['tool_id'] = tool_id
                namespace["galaxy_interactor"] = galaxy_interactor
                namespace['master_api_key'] = master_api_key
                namespace[
                    'user_api_key'] = user_api_key or galaxy_interactor.api_key
                namespace['test_count'] = count

                all_versions_test_count += 1

            # Create new class object, with name name, derived
            # from baseclasses (which should be a tuple of classes) and with namespace dict.
            new_class_obj = type(str(name), baseclasses, namespace)
            G[name] = new_class_obj
    return G