Esempio n. 1
0
    def run(self):
        # first let's get the steps
        all_steps = self._data_loader.load_file(self._test_file)

        # iterate through all includes
        all_steps = self._resolve_all_includes(all_steps)

        self._start_selenium()

        try:
            for step in all_steps:
                # run each step

                step = iterate_dict(step,
                                    variable_manager=self._variable_manager)

                if 'store' in step:
                    var_name = step['store']
                    del step['store']

                    if 'when' in step:
                        result = parse_jinja(
                            step['when'],
                            variable_manager=self._variable_manager)
                        if result:
                            _, _, retval = self._run_step(step)
                            self._variable_manager.add_var({var_name: retval})
                    else:
                        _, _, retval = self._run_step(step)
                        self._variable_manager.add_var({var_name: retval})
                else:
                    if 'when' in step:
                        result = parse_jinja(
                            step['when'],
                            variable_manager=self._variable_manager)
                        if result:
                            self._run_step(step)
                    else:
                        self._run_step(step)
        finally:
            self._webdriver.quit()

        return os.path.basename(self._test_file), all_steps
Esempio n. 2
0
def load_aut_vars(loader, options, variable_manager):
    aut_vars = dict()
    if options and options.application:
        # first, load in default.yml, then override with $application.yml
        aut_vars = loader.load_file(
            os.path.abspath(os.path.join(os.path.curdir, "apps",
                                         "default.yml")))

        if options.application != "default.yml":
            # don't load default.yml twice.
            aut_vars = merge_dict(
                aut_vars,
                loader.load_file(
                    os.path.abspath(
                        os.path.join(os.path.curdir, "apps",
                                     options.application))))

    return iterate_dict(aut_vars,
                        variable_manager=variable_manager,
                        parse_kv=False)
Esempio n. 3
0
    def _resolve_test_vars(self):
        test_vars = dict()

        vars_files = (
            glob.iglob(os.path.join(self._test_path, "vars", "*.yml"),
                       recursive=True),
            glob.iglob(os.path.join(self._test_path, "vars", "*.yaml"),
                       recursive=True),
            glob.iglob(os.path.join(self._test_path, "vars", "*.json"),
                       recursive=True),
        )

        for possible_var_files in vars_files:
            for vars_file in possible_var_files:
                if os.path.exists(vars_file):
                    test_vars = merge_dict(
                        test_vars, self._data_loader.load_file(vars_file))

        return iterate_dict(test_vars,
                            variable_manager=self._variable_manager,
                            parse_kv=False)
Esempio n. 4
0
def load_vars(loader, options, variable_manager):
    variables = dict()

    all_var_files = (
        glob.iglob(os.path.join(os.path.curdir, "vars", "*.yml"),
                   recursive=True),
        glob.iglob(os.path.join(os.path.curdir, "vars", "*.yaml"),
                   recursive=True),
        glob.iglob(os.path.join(os.path.curdir, "vars", "*.json"),
                   recursive=True),
    )

    for possible_var_files in all_var_files:
        for var_files in possible_var_files:
            variables = merge_dict(
                variables, loader.load_file(os.path.abspath(var_files)))

    # don't parsekv for variables
    return iterate_dict(variables,
                        variable_manager=variable_manager,
                        parse_kv=False)
Esempio n. 5
0
    def run(self):
        # first let's get the steps
        all_steps = self._data_loader.load_file(self._test_file)

        # iterate through all includes
        all_steps = self._resolve_all_includes(all_steps)

        self._start_selenium()

        try:
            for step in all_steps:
                # run each step

                step = iterate_dict(step,
                                    variable_manager=self._variable_manager)

                if 'store' in step:
                    var_name = step['store']
                    del step['store']

                    _, _, retval = Step(
                        step,
                        data_loader=self._data_loader,
                        variable_manager=self._variable_manager,
                        modules=self._modules,
                        webdriver=self._webdriver,
                        keywords=self._keywords).run()
                    self._variable_manager.add_var({var_name: retval})
                else:
                    Step(step,
                         data_loader=self._data_loader,
                         variable_manager=self._variable_manager,
                         modules=self._modules,
                         webdriver=self._webdriver,
                         keywords=self._keywords).run()
        finally:
            self._webdriver.quit()

        return os.path.basename(self._test_file), all_steps