Exemplo n.º 1
0
 def _create_execution_directory(self):
     """Generate the execution report directory"""
     if self.is_suite:
         execution_directory = report.create_execution_directory(
             self.project, self.timestamp, suite_name=self.suite_name)
     else:
         execution_directory = report.create_execution_directory(
             self.project, self.timestamp, test_name=self.test_name)
     return execution_directory
Exemplo n.º 2
0
def _create_execution_directory(workspace, project, timestamp, test_name,
                                suite_name, is_suite):
    """Generate the execution directory."""
    execution_directory = ''
    if is_suite:
        execution_directory = report.create_execution_directory(
            workspace, project, timestamp, suite_name=suite_name)
    else:
        execution_directory = report.create_execution_directory(
            workspace, project, timestamp, test_name=test_name)
    return execution_directory
Exemplo n.º 3
0
 def test_create_report_directory_suite(self, project_session):
     timestamp = utils.get_timestamp()
     test_name = 'testing_report_002'
     exec_dir = report.create_execution_directory(project_session.testdir,
                                                  project_session.name, timestamp,
                                                  test_name=test_name)
     directory = report.create_report_directory(exec_dir, test_name, is_suite=True)
     assert os.path.isdir(directory)
Exemplo n.º 4
0
 def test_create_report_directory_test(self, project_session):
     project = project_session.name
     testdir = project_session.testdir
     timestamp = utils.get_timestamp()
     test_name = 'testing_report_001'
     exec_dir = report.create_execution_directory(testdir, project, timestamp,
                                                  test_name=test_name)
     directory = report.create_report_directory(exec_dir, test_name, is_suite=False)
     assert os.path.isdir(directory)
Exemplo n.º 5
0
 def test_create_execution_directory_test(self, project_session):
     project = project_session.name
     testdir = project_session.testdir
     timestamp = utils.get_timestamp()
     test_name = 'test_execution_directory'
     directory = report.create_execution_directory(testdir, project, timestamp,
                                                   test_name=test_name)
     path = os.path.join(project_session.path, 'reports', 'single_tests', test_name, timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 6
0
 def test_create_execution_directory_suite_parents(self, project_session):
     project = project_session.name
     testdir = project_session.testdir
     timestamp = utils.get_timestamp()
     suite_name = 'a.b.suite_execution_directory'
     directory = report.create_execution_directory(testdir, project, timestamp,
                                                   suite_name=suite_name)
     path = os.path.join(project_session.path, 'reports', suite_name, timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 7
0
 def test_create_execution_directory_suite(self, project_session):
     project = project_session['name']
     testdir = project_session['testdir']
     timestamp = utils.get_timestamp()
     suite_name = 'suite_execution_directory'
     directory = report.create_execution_directory(testdir, project, timestamp,
                                                   suite_name=suite_name)
     path = os.path.join(testdir, 'projects', project, 'reports',
                         suite_name, timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 8
0
 def test_create_execution_directory_test_parents(self, project_session):
     project = project_session['name']
     testdir = project_session['testdir']
     timestamp = utils.get_timestamp()
     test_name = 'a.b.test_execution_directory'
     directory = report.create_execution_directory(testdir, project, timestamp,
                                                   test_name=test_name)
     path = os.path.join(testdir, 'projects', project, 'reports',
                         'single_tests', test_name, timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 9
0
 def test_create_execution_directory_suite(self, project_session):
     testdir, project = project_session.activate()
     timestamp = utils.get_timestamp()
     suite_name = 'suite_execution_directory'
     directory = report.create_execution_directory(project,
                                                   timestamp,
                                                   suite_name=suite_name)
     path = os.path.join(project_session.path, 'reports', suite_name,
                         timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 10
0
    def test_generate_report_with_env(self, permanent_project_fixture):
        project = permanent_project_fixture['name']
        testdir = permanent_project_fixture['testdir']
        timestamp = utils.get_timestamp()
        test_name = 'testing_report_003'
        exec_dir = report.create_execution_directory(testdir,
                                                     project,
                                                     timestamp,
                                                     test_name=test_name)
        report_dir = report.create_report_directory(exec_dir,
                                                    test_name,
                                                    is_suite=True)
        test_data = {
            'env': {
                'name': 'env01',
                'url': '1.1.1.1'
            },
            'var2': 'value2'
        }
        test_data = test_runner.Data(test_data)

        result = {
            'result': 'pass',
            'error': '',
            'description': 'description of the test',
            'steps': ['step1', 'step2'],
            'test_elapsed_time': 22.22,
            'test_timestamp': '2018.02.04.02.16.42.729',
            'browser': 'chrome',
            'browser_full_name': '',
            'set_name': 'set_001',
        }
        report.generate_report(report_dir, test_name, test_data, result)
        expected = {
            'test_case': test_name,
            'result': 'pass',
            'steps': ['step1', 'step2'],
            'description': 'description of the test',
            'error': '',
            'short_error': '',
            'test_elapsed_time': 22.22,
            'test_timestamp': '2018.02.04.02.16.42.729',
            'browser': 'chrome',
            'environment': 'env01',
            'set_name': 'set_001',
            'test_data': {
                'env': "{'name': 'env01', 'url': '1.1.1.1'}",
                'var2': "'value2'"
            }
        }
        path = os.path.join(report_dir, 'report.json')
        with open(path) as report_file:
            actual = json.load(report_file)
            assert actual == expected
Exemplo n.º 11
0
 def test_create_report_directory_suite(self, permanent_project_fixture):
     project = permanent_project_fixture['name']
     testdir = permanent_project_fixture['testdir']
     timestamp = utils.get_timestamp()
     test_name = 'testing_report_002'
     exec_dir = report.create_execution_directory(testdir,
                                                  project,
                                                  timestamp,
                                                  test_name=test_name)
     directory = report.create_report_directory(exec_dir,
                                                test_name,
                                                is_suite=True)
     assert os.path.isdir(directory)
Exemplo n.º 12
0
 def test_create_execution_directory_test(self, permanent_project_fixture):
     project = permanent_project_fixture['name']
     testdir = permanent_project_fixture['testdir']
     timestamp = utils.get_timestamp()
     test_name = 'test_execution_directory'
     directory = report.create_execution_directory(testdir,
                                                   project,
                                                   timestamp,
                                                   test_name=test_name)
     path = os.path.join(testdir, 'projects', project, 'reports',
                         'single_tests', test_name, timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 13
0
 def test_generate_report(self, project_session):
     project = project_session['name']
     testdir = project_session['testdir']
     timestamp = utils.get_timestamp()
     test_name = 'testing_report_002'
     exec_dir = report.create_execution_directory(testdir, project, timestamp,
                                                  test_name=test_name)
     report_dir = report.create_report_directory(exec_dir, test_name,
                                                 is_suite=True)
     test_data = {
         'var1': 'value1',
         'var2': 'value2'
     }
     result = {
         'result': 'pass',
         'error': '',
         'description': 'description of the test',
         'steps': ['step1', 'step2'],
         'test_elapsed_time': 22.22,
         'test_timestamp': '2018.02.04.02.16.42.729',
         'browser': 'chrome',
         'browser_full_name': '',
         'set_name': 'set_001',
     }
     report.generate_report(report_dir, test_name, test_data, result, timestamp, hash(timestamp + str(test_data)))
     expected = {
         'test_case': test_name,
         'result': 'pass',
         'steps': ['step1', 'step2'],
         'description': 'description of the test',
         'error': '',
         'short_error': '',
         'test_elapsed_time': 22.22,
         'test_timestamp': '2018.02.04.02.16.42.729',
         'browser': 'chrome',
         'environment': '',
         'set_name': 'set_001',
         'suite_timestamp': timestamp,
         'test_id': hash(timestamp + str(test_data)),
         'user': getpass.getuser(),
         'hostname': socket.gethostname(),
         'test_data': {
             'var1': "'value1'",
             'var2': "'value2'"
         }
     }
     path = os.path.join(report_dir, 'report.json')
     with open(path) as report_file:
         actual = json.load(report_file)
         assert actual == expected
Exemplo n.º 14
0
 def test_create_execution_directory_suite_parents(
         self, permanent_project_fixture):
     project = permanent_project_fixture['name']
     testdir = permanent_project_fixture['testdir']
     timestamp = utils.get_timestamp()
     suite_name = 'a.b.suite_execution_directory'
     directory = report.create_execution_directory(testdir,
                                                   project,
                                                   timestamp,
                                                   suite_name=suite_name)
     path = os.path.join(testdir, 'projects', project, 'reports',
                         suite_name, timestamp)
     assert os.path.isdir(path)
     assert directory == path
Exemplo n.º 15
0
 def test_generate_report_with_env(self, project_session):
     timestamp = utils.get_timestamp()
     test_name = 'testing_report_003'
     exec_dir = report.create_execution_directory(project_session.testdir,
                                                  project_session.name, timestamp,
                                                  test_name=test_name)
     report_dir = report.create_report_directory(exec_dir, test_name, is_suite=True)
     test_data = {
         'env': {
             'name': 'env01',
             'url': '1.1.1.1'
         },
         'var2': 'value2'
     }
     test_data = test_runner.Data(test_data)
     result = {
         'result': 'success',
         'errors': [],
         'description': 'description of the test',
         'steps': [
             {'message': 'step1', 'screenshot': None, 'error': None},
             {'message': 'step2', 'screenshot': None, 'error': None}
         ],
         'test_elapsed_time': 22.22,
         'test_timestamp': '2018.02.04.02.16.42.729',
         'browser': 'chrome',
         'browser_full_name': '',
         'set_name': 'set_001',
     }
     report.generate_report(report_dir, test_name, test_data, result)
     path = os.path.join(report_dir, 'report.json')
     with open(path) as report_file:
         actual = json.load(report_file)
         assert len(actual.items()) == 11
         assert actual['test_case'] == test_name
         assert actual['result'] == 'success'
         assert actual['steps'][0]['message'] == 'step1'
         assert actual['steps'][1]['message'] == 'step2'
         assert actual['description'] == 'description of the test'
         assert actual['errors'] == []
         assert actual['test_elapsed_time'] == 22.22
         assert actual['test_timestamp'] == '2018.02.04.02.16.42.729'
         assert actual['browser'] == 'chrome'
         assert actual['environment'] == 'env01'
         assert actual['set_name'] == 'set_001'
         test_data_a = "{'url': '1.1.1.1', 'name': 'env01'}"
         test_data_b = "{'name': 'env01', 'url': '1.1.1.1'}"
         assert actual['test_data']['env'] in [test_data_a, test_data_b]
         assert actual['test_data']['var2'] == "'value2'"