Example #1
0
 def test_golem_run_test_py_in_folder(self, project_function, test_utils, caplog):
     project = project_function.name
     test_utils.create_test(project_function.testdir, project, ['folder'], 'test_one')
     commands.run_command(project=project, test_query='folder/test_one.py')
     records = caplog.records
     assert records[0].message == 'Test execution started: folder.test_one'
     assert records[4].message == 'Test Result: SUCCESS'
Example #2
0
 def test_golem_run_project_does_not_exist(self, project_session):
     project_session.activate()
     with pytest.raises(SystemExit) as excinfo:
         commands.run_command(project='incorrect')
     assert str(
         excinfo.value
     ) == 'golem run: error: the project incorrect does not exist'
Example #3
0
 def test_golem_run_test_py_in_folder_windows_path(self, project_function,
                                                   test_utils, caplog):
     _, project = project_function.activate()
     test_utils.create_test(project, 'folder.test_one')
     commands.run_command(project=project, test_query='folder\\test_one.py')
     records = caplog.records
     assert records[0].message == 'Test execution started: folder.test_one'
     assert records[4].message == 'Test Result: SUCCESS'
Example #4
0
 def test_golem_run_test_in_folder(self, project_session, test_utils,
                                   caplog):
     _, project = project_session.activate()
     test_name = f'{test_utils.random_string()}.test_one'
     test_utils.create_test(project, test_name)
     commands.run_command(project=project, test_query=test_name)
     records = caplog.records
     assert records[0].message == f'Test execution started: {test_name}'
     assert records[3].message == 'Test Result: SUCCESS'
Example #5
0
 def test_golem_run_suite_py_in_folder(self, project_function, test_utils, caplog):
     project = project_function.name
     test_name = 'test_one'
     test_utils.create_test(project_function.testdir, project, [], test_name)
     test_utils.create_suite(project_function.testdir, project, ['folder'], 'suite_one', tests=[test_name])
     commands.run_command(project=project, test_query='folder/suite_one.py')
     records = caplog.records
     assert records[0].message == 'Test execution started: {}'.format(test_name)
     assert records[4].message == 'Test Result: SUCCESS'
Example #6
0
 def test_golem_run_suite_py(self, project_session, test_utils, caplog):
     _, project = project_session.activate()
     test_name = test_utils.create_random_test(project)
     suite_name = test_utils.random_string()
     test_utils.create_suite(project, suite_name, tests=[test_name])
     with_extension = suite_name + '.py'
     commands.run_command(project=project, test_query=with_extension)
     records = caplog.records
     assert records[0].message == f'Test execution started: {test_name}'
     assert records[3].message == 'Test Result: SUCCESS'
Example #7
0
    def test_exit_code_one_on_test_failure_when_using_multi_processing_capabilities(
            self, project_function, test_utils):
        _, project = project_function.activate()
        test_utils.create_test(project, 'test_one', content=self.content)
        test_utils.create_test(project, 'test_two')

        with pytest.raises(SystemExit) as wrapped_execution:
            commands.run_command(project=project, test_query='.', processes=2)

        assert wrapped_execution.value.code == 1
Example #8
0
 def test_golem_run_test(self, project_session, test_utils, caplog):
     _, project = project_session.activate()
     test_name = test_utils.create_random_test(project)
     commands.run_command(project=project, test_query=test_name)
     records = caplog.records
     assert records[0].message == f'Test execution started: {test_name}'
     assert records[3].message == 'Test Result: SUCCESS'
     # the execution report is created for suite
     path = os.path.join(project_session.path, 'reports', test_name)
     assert os.path.isdir(path)
     # only one timestamp
     assert len(os.listdir(path)) == 1
Example #9
0
 def test_golem_run_suite_py_in_folder(self, project_session, test_utils,
                                       caplog):
     _, project = project_session.activate()
     test_name = test_utils.create_random_test(project)
     random_dir = test_utils.random_string()
     suite_name = f'{random_dir}.suite_one'
     suite_query = os.path.join(random_dir, 'suite_one.py')
     test_utils.create_suite(project, suite_name, tests=[test_name])
     commands.run_command(project=project, test_query=suite_query)
     records = caplog.records
     assert records[0].message == f'Test execution started: {test_name}'
     assert records[3].message == 'Test Result: SUCCESS'
Example #10
0
 def test_golem_run_suite_in_folder(self, project_session, test_utils,
                                    caplog, capsys):
     testdir, project = project_session.activate()
     test_name = test_utils.create_random_test(project)
     suite_name = f'{test_utils.random_string()}.{test_utils.random_string()}'
     test_utils.create_suite(project, suite_name, tests=[test_name])
     commands.run_command(project=project, test_query=suite_name)
     records = caplog.records
     assert records[0].message == f'Test execution started: {test_name}'
     assert records[3].message == 'Test Result: SUCCESS'
     out, err = capsys.readouterr()
     assert 'Tests found: 1' in out
Example #11
0
 def test_golem_run_suite_py_in_folder_windows_path(self, project_function,
                                                    test_utils, caplog):
     _, project = project_function.activate()
     test_name = 'test_one'
     test_utils.create_test(project, [], test_name)
     test_utils.create_suite(project, 'folder.suite_one', tests=[test_name])
     commands.run_command(project=project,
                          test_query='folder\\suite_one.py')
     records = caplog.records
     assert records[0].message == 'Test execution started: {}'.format(
         test_name)
     assert records[4].message == 'Test Result: SUCCESS'
Example #12
0
 def test_golem_run_test_py(self, project_function, test_utils, caplog):
     project = project_function.name
     test_name = 'test_one'
     test_utils.create_test(project_function.testdir, project, [], test_name)
     commands.run_command(project=project, test_query='test_one.py')
     records = caplog.records
     assert records[0].message == 'Test execution started: {}'.format(test_name)
     assert records[4].message == 'Test Result: SUCCESS'
     # the execution report is created for suite
     path = os.path.join(project_function.path, 'reports', 'single_tests', 'test_one')
     assert os.path.isdir(path)
     # only one timestamp
     assert len(os.listdir(path)) == 1
Example #13
0
 def test_golem_run_suite_in_folder(self, project_function, test_utils,
                                    caplog, capsys):
     testdir, project = project_function.activate()
     test_name = 'test_one'
     test_utils.create_test(project, [], test_name)
     test_utils.create_suite(project, 'folder.suite_one', tests=[test_name])
     commands.run_command(project=project, test_query='folder.suite_one')
     records = caplog.records
     assert records[0].message == 'Test execution started: {}'.format(
         test_name)
     assert records[4].message == 'Test Result: SUCCESS'
     out, err = capsys.readouterr()
     assert 'Tests found: 1' in out
Example #14
0
    def test_golem_run_directory_no_tests_present(self, project_function):
        project = project_function.name
        with pytest.raises(SystemExit) as excinfo:
            commands.run_command(project=project, test_query='.')
        msg = ('No tests were found in {}'.format(os.path.join('tests', '')))
        assert str(excinfo.value) == msg

        path = os.path.join(project_function.path, 'tests', 'foo')
        file_manager.create_directory(path=path, add_init=True)
        with pytest.raises(SystemExit) as excinfo:
            commands.run_command(project=project, test_query='foo')
        msg = ('No tests were found in {}'.format(os.path.join('tests',
                                                               'foo')))
        assert str(excinfo.value) == msg
Example #15
0
 def test_golem_run_suite(self, project_function, test_utils, caplog):
     project = project_function.name
     test_name = 'test_one'
     test_utils.create_test(project_function.testdir, project, [], test_name)
     test_utils.create_suite(project_function.testdir, project, [], 'suite_one', tests=[test_name])
     commands.run_command(project=project, test_query='suite_one')
     records = caplog.records
     assert records[0].message == 'Test execution started: {}'.format(test_name)
     assert records[4].message == 'Test Result: SUCCESS'
     # the execution report is created for suite
     path = os.path.join(project_function.path, 'reports', 'suite_one')
     assert os.path.isdir(path)
     timestamp = os.listdir(path)[0]
     report = os.path.join(path, timestamp, 'execution_report.json')
     assert os.path.isfile(report)
Example #16
0
 def test_golem_run_directory_no_tests_present(self, project_function,
                                               capsys):
     _, project = project_function.activate()
     # run all tests, there are no tests in project
     commands.run_command(project=project, test_query='.')
     msg = 'No tests were found in {}'.format(os.path.join('tests', ''))
     out, err = capsys.readouterr()
     assert msg in out
     # run tests in an empty directory
     path = os.path.join(project_function.path, 'tests', 'foo')
     file_manager.create_directory(path=path, add_init=True)
     commands.run_command(project=project, test_query='foo')
     msg = 'No tests were found in {}'.format(os.path.join('tests', 'foo'))
     out, err = capsys.readouterr()
     assert msg in out
Example #17
0
 def test_golem_run_suite(self, project_session, test_utils, caplog):
     _, project = project_session.activate()
     test_name = test_utils.create_random_test(project)
     suite_name = test_utils.random_string()
     test_utils.create_suite(project, suite_name, tests=[test_name])
     commands.run_command(project=project, test_query=suite_name)
     records = caplog.records
     assert records[0].message == 'Test execution started: {}'.format(
         test_name)
     assert records[2].message == 'Test Result: SUCCESS'
     # the execution report is created for suite
     path = os.path.join(project_session.path, 'reports', suite_name)
     assert os.path.isdir(path)
     timestamp = os.listdir(path)[0]
     report = os.path.join(path, timestamp, 'report.json')
     assert os.path.isfile(report)
Example #18
0
 def test_golem_run_directory_all_tests(self, project_function, test_utils):
     _, project = project_function.activate()
     test_utils.create_test(project, 'test_one')
     test_utils.create_test(project, 'foo.test_two')
     test_utils.create_test(project, 'foo.bar.test_three')
     commands.run_command(project=project, test_query='.')
     reportsdir = os.path.join(project_function.path, 'reports', 'all')
     assert os.path.isdir(reportsdir)
     assert len(os.listdir(reportsdir)) == 1
     timestamp = os.listdir(reportsdir)[0]
     timestampdir = os.path.join(reportsdir, timestamp)
     tests = os.listdir(timestampdir)
     assert len(tests) == 4
     assert 'test_one' in tests
     assert 'foo.test_two' in tests
     assert 'foo.bar.test_three' in tests
Example #19
0
 def test_golem_run_suite(self, project_session, test_utils, caplog):
     _, project = project_session.activate()
     test_name = test_utils.create_random_test(project)
     suite_name = test_utils.random_string()
     test_utils.create_suite(project, suite_name, tests=[test_name])
     timestamp = utils.get_timestamp()
     commands.run_command(project=project,
                          test_query=suite_name,
                          timestamp=timestamp)
     records = caplog.records
     assert records[0].message == f'Test execution started: {test_name}'
     assert records[3].message == 'Test Result: SUCCESS'
     # the execution report is created for suite
     path = os.path.join(
         execution_report.execution_report_path(project, suite_name,
                                                timestamp), 'report.json')
     assert os.path.isfile(path)
Example #20
0
 def test_golem_run_directory(self, project_function, test_utils):
     project = project_function.name
     test_utils.create_test(project_function.testdir, project, [], 'test_one')
     test_utils.create_test(project_function.testdir, project, ['foo'], 'test_two')
     test_utils.create_test(project_function.testdir, project, ['foo'], 'test_three')
     test_utils.create_test(project_function.testdir, project, ['foo', 'bar'], 'test_four')
     commands.run_command(project=project, test_query='foo')
     reportsdir = os.path.join(project_function.path, 'reports', 'foo')
     assert os.path.isdir(reportsdir)
     assert len(os.listdir(reportsdir)) == 1
     timestamp = os.listdir(reportsdir)[0]
     timestampdir = os.path.join(reportsdir, timestamp)
     tests = os.listdir(timestampdir)
     assert len(tests) == 4
     assert 'foo.test_two' in tests
     assert 'foo.test_three' in tests
     assert 'foo.bar.test_four' in tests
     assert 'test_one' not in tests
Example #21
0
 def _run_command(project_name, suite_name, timestamp=None):
     if not timestamp:
         timestamp = utils.get_timestamp()
     commands.run_command(project_name, suite_name, timestamp=timestamp)
     return timestamp
Example #22
0
 def test_golem_run_missing_test_query(self, project_session, capsys):
     _, project = project_session.activate()
     commands.run_command(project=project)
     captured = capsys.readouterr()
     assert messages.RUN_USAGE_MSG in captured.out
Example #23
0
 def test_golem_run_project_param_is_missing(self, project_session, capsys):
     project_session.activate()
     commands.run_command()
     captured = capsys.readouterr()
     assert messages.RUN_USAGE_MSG in captured.out