Beispiel #1
0
 def test_set_execution_module_runner_values(self, project_class,
                                             test_utils):
     testdir, project = project_class.activate()
     test_name = test_utils.create_random_test(project)
     test = test_module.Test(project, test_name)
     report_directory = _mock_report_directory(testdir, project, test_name)
     settings = settings_manager.get_project_settings(project)
     browser = _define_browsers_mock(['chrome'])[0]
     test_data = {}
     secrets = {}
     env_name = 'foo'
     runner = test_runner.TestRunner(testdir, project, test_name, test_data,
                                     secrets, browser, env_name, settings,
                                     report_directory)
     runner._set_execution_module_values()
     from golem import execution
     attrs = [x for x in dir(execution) if not x.startswith('_')]
     assert len(attrs) == 20
     assert execution.browser is None
     assert execution.browser_definition == browser
     assert execution.browsers == {}
     assert execution.steps == []
     assert execution.data == {}
     assert execution.secrets == {}
     assert execution.description is None
     assert execution.errors == []
     assert execution.settings == settings
     assert execution.test_name == test_name
     assert execution.test_dirname == test.dirname
     assert execution.test_path == test.path
     assert execution.project_name == project
     assert execution.project_path == test.project.path
     assert execution.testdir == testdir
     assert execution.report_directory == report_directory
     assert execution.logger is None
     assert execution.timers == {}
     assert execution.tags == []
     assert execution.environment == env_name
Beispiel #2
0
    def test_set_execution_module_runner_values(self, project_module,
                                                test_utils):
        testdir, project = project_module.activate()
        test_file = test_utils.create_random_test(project)
        test = test_module.Test(project, test_file)
        timestamp = utils.get_timestamp()
        executiondir = _mock_report_directory(project, test_file, timestamp)
        testfile_reportdir = test_report.test_file_report_dir(
            test_file, execdir=executiondir)
        settings = settings_manager.get_project_settings(project)
        browser = _define_browsers_mock(['chrome'])[0]
        test_data = {}
        secrets = {}
        env_name = 'foo'
        runner = test_runner.TestRunner(testdir,
                                        project,
                                        test_file,
                                        test_data,
                                        secrets,
                                        browser,
                                        env_name,
                                        settings,
                                        executiondir,
                                        set_name='')
        runner._set_execution_module_values()
        from golem import execution
        attrs = [x for x in dir(execution) if not x.startswith('_')]
        assert len(attrs) == 23
        assert execution.browser is None
        assert execution.browser_definition == browser
        assert execution.browsers == {}
        assert execution.data == {}
        assert execution.secrets == {}
        assert execution.description is None
        assert execution.settings == settings
        assert execution.test_file == test_file
        assert execution.test_dirname == test.dirname
        assert execution.test_path == test.path
        assert execution.project_name == project
        assert execution.project_path == test.project.path
        assert execution.testdir == testdir
        assert execution.execution_reportdir == executiondir
        assert execution.testfile_reportdir is None  # Not populated at this point
        assert execution.logger is None
        assert execution.tags == []
        assert execution.environment == env_name

        assert execution.test_name is None
        assert execution.steps == []
        assert execution.errors == []
        assert execution.test_reportdir is None
        assert execution.timers == {}

        # test _reset_execution_module_values_for_test_function
        execution.test_name = 'foo'
        execution.steps = ['foo']
        execution.errors = ['foo']
        execution.report_directory = 'foo'
        execution.timers = {'foo': 'bar'}

        runner._reset_execution_module_values_for_test_function(
            test_reportdir='x', test_name='test-name')
        assert execution.test_name == 'test-name'
        assert execution.steps == []
        assert execution.errors == []
        assert execution.test_reportdir == 'x'
        assert execution.timers == {}