Example #1
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
Example #2
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'"