Ejemplo n.º 1
0
    def test_define_execution_list(self, testdir_fixture):
        """Verify that the execution list is generated properly when there's only
        one test without datasets, one driver and zero environments
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        test_name = 'new_test_case_001'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name)

        execution = {
            'tests': [test_name],
            'workers': 1,
            'drivers': ['chrome'],
            'environments': [''],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(root_path, project, execution)
        
        expected_list = [
            {
                'test_name': 'new_test_case_001',
                'data_set': {},
                'driver': 'chrome',
                'report_directory': None
            }
        ]
        assert execution_list == expected_list
Ejemplo n.º 2
0
    def test_define_execution_list_multiple_tests(self, testdir_fixture):
        """Verify that the execution list is generated properly when there
        are multiple tests in the list
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        # create test one
        test_name_one = 'new_test_case_one'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name_one)
        tdata = [{
            'col1': 'a',
            'col2': 'b'
        }, {
            'col1': 'c',
            'col2': 'd',
        }]
        test_data.save_external_test_data_file(root_path, project,
                                               test_name_one, tdata)

        # create test two
        test_name_two = 'new_test_case_two'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name_two)

        execution = {
            'tests': [test_name_one, test_name_two],
            'workers': 1,
            'drivers': ['chrome'],
            'environments': [''],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(
            root_path, project, execution)

        expected_list = [{
            'test_name': 'new_test_case_one',
            'data_set': {
                'col1': 'a',
                'col2': 'b'
            },
            'driver': 'chrome',
            'report_directory': None
        }, {
            'test_name': 'new_test_case_one',
            'data_set': {
                'col1': 'c',
                'col2': 'd'
            },
            'driver': 'chrome',
            'report_directory': None
        }, {
            'test_name': 'new_test_case_two',
            'data_set': {},
            'driver': 'chrome',
            'report_directory': None
        }]
        assert execution_list == expected_list
Ejemplo n.º 3
0
    def test_define_execution_list(self, testdir_fixture):
        """Verify that the execution list is generated properly when there's only
        one test without datasets, one driver and zero environments
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        test_name = 'new_test_case_001'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name)

        execution = {
            'tests': [test_name],
            'workers': 1,
            'drivers': ['chrome'],
            'environments': [''],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(
            root_path, project, execution)

        expected_list = [{
            'test_name': 'new_test_case_001',
            'data_set': {},
            'driver': 'chrome',
            'report_directory': None
        }]
        assert execution_list == expected_list
Ejemplo n.º 4
0
    def test_define_execution_list_multiple_drivers(self, testdir_fixture):
        """Verify that the execution list is generated properly when there
        are multiple drivers in the list
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        # create test one
        test_name_one = 'new_test_case_one'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name_one)
        # create test two
        test_name_two = 'new_test_case_two'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name_two)

        execution = {
            'tests': [test_name_one, test_name_two],
            'workers': 1,
            'drivers': ['chrome', 'firefox'],
            'environments': [''],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(root_path, project,
                                                                execution)
        
        expected_list = [
            {
                'test_name': 'new_test_case_one',
                'data_set': {},
                'driver': 'chrome',
                'report_directory': None
            },
            {
                'test_name': 'new_test_case_one',
                'data_set': {},
                'driver': 'firefox',
                'report_directory': None
            },
            {
                'test_name': 'new_test_case_two',
                'data_set': {},
                'driver': 'chrome',
                'report_directory': None
            },
            {
                'test_name': 'new_test_case_two',
                'data_set': {},
                'driver': 'firefox',
                'report_directory': None
            }
        ]
        assert execution_list == expected_list
Ejemplo n.º 5
0
    def test_define_execution_list_multiple_envs(self, testdir_fixture):
        """Verify that the execution list is generated properly when the execution
        has multiple envs
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        # create test one
        test_name_one = 'new_test_case_one'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name_one)

        # create two environments in environments.json
        env_data = {"stage": {"url": "xxx"}, "preview": {"url": "yyy"}}
        env_data_json = json.dumps(env_data)
        environment_manager.save_environments(root_path, project,
                                              env_data_json)

        execution = {
            'tests': [test_name_one],
            'workers': 1,
            'drivers': ['chrome'],
            'environments': ['stage', 'preview'],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(
            root_path, project, execution)

        expected_list = [
            {
                'test_name': 'new_test_case_one',
                'data_set': {
                    'env': {
                        'url': 'xxx',
                        'name': 'stage'
                    }
                },
                'driver': 'chrome',
                'report_directory': None
            },
            {
                'test_name': 'new_test_case_one',
                'data_set': {
                    'env': {
                        'url': 'yyy',
                        'name': 'preview'
                    }
                },
                'driver': 'chrome',
                'report_directory': None
            },
        ]
        assert execution_list == expected_list
Ejemplo n.º 6
0
    def test_define_execution_list_multiple_envs(self, testdir_fixture):
        """Verify that the execution list is generated properly when the execution
        has multiple envs
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        # create test one
        test_name_one = 'new_test_case_one'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name_one)

        # create two environments in environments.json
        env_data = {
            "stage": {
                "url": "xxx"
            },
            "preview": {
                "url": "yyy"
            }
        }
        env_data_json = json.dumps(env_data)
        environment_manager.save_environments(root_path, project, env_data_json)

        execution = {
            'tests': [test_name_one],
            'workers': 1,
            'drivers': ['chrome'],
            'environments': ['stage', 'preview'],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(root_path, project,
                                                                execution)
        
        expected_list = [
            {
                'test_name': 'new_test_case_one',
                'data_set': {'env': {'url': 'xxx', 'name': 'stage'}},
                'driver': 'chrome',
                'report_directory': None
            },
            {
                'test_name': 'new_test_case_one',
                'data_set': {'env': {'url': 'yyy', 'name': 'preview'}},
                'driver': 'chrome',
                'report_directory': None
            },
        ]
        assert execution_list == expected_list
Ejemplo n.º 7
0
    def test_define_execution_list_multiple_data_sets(self, testdir_fixture):
        """Verify that the execution list is generated properly when a test
        has multiple data sets
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        test_name = 'new_test_case_002'
        parents = []
        test_case.new_test_case(root_path, project, parents, test_name)

        tdata = [
            {
                'col1': 'a',
                'col2': 'b'
            },
            {
                'col1': 'c',
                'col2': 'd',
            }

        ]
        test_data.save_external_test_data_file(root_path, project, test_name, tdata)

        execution = {
            'tests': [test_name],
            'workers': 1,
            'drivers': ['chrome'],
            'environments': [''],
            'suite_before': None,
            'suite_after': None
        }

        execution_list = start_execution._define_execution_list(root_path, project,
                                                                execution)
        
        expected_list = [
            {
                'test_name': 'new_test_case_002',
                'data_set': {'col1': 'a', 'col2': 'b'},
                'driver': 'chrome',
                'report_directory': None
            },
            {
                'test_name': 'new_test_case_002',
                'data_set': {'col1': 'c', 'col2': 'd'},
                'driver': 'chrome',
                'report_directory': None
            }
        ]
        assert execution_list == expected_list
Ejemplo n.º 8
0
 def test_get_files_dot_path(self, testdir_fixture):
     project = helper_functions.create_random_project(
         testdir_fixture['path'])
     # create a new page object in pages folder
     page_object.new_page_object(testdir_fixture['path'], project, [],
                                 'page1')
     # create a new page object in pages/dir/subdir/
     page_object.new_page_object(testdir_fixture['path'], project,
                                 ['dir', 'subdir'], 'page2')
     base_path = os.path.join(testdir_fixture['path'], 'projects', project,
                              'pages')
     dot_files = file_manager.get_files_dot_path(base_path)
     expected_result = ['page1', 'dir.subdir.page2']
     assert dot_files == expected_result
Ejemplo n.º 9
0
 def test_get_files_dot_path_extension(self, testdir_fixture):
     project = helper_functions.create_random_project(testdir_fixture['path'])
     testdir = testdir_fixture['path']
     # create a new page object in pages folder (.py extension)
     page_object.new_page_object(testdir, project, [], 'page2')
     # create a file with another extension
     another_extension = os.path.join(testdir, 'projects', project,
                                      'pages', 'another.json')
     with open(another_extension, 'w') as another_file:
         another_file.write('')
     base_path = os.path.join(testdir_fixture['path'], 'projects',
                              project, 'pages')
     dot_files = file_manager.get_files_dot_path(base_path, extension='.py')
     expected_result = ['page2']
     assert dot_files == expected_result
Ejemplo n.º 10
0
 def test_get_files_in_directory_dot_path(self, testdir_fixture):
     project = helper_functions.create_random_project(
         testdir_fixture['path'])
     # create a new page object in pages folder
     page_object.new_page_object(testdir_fixture['path'], project, [],
                                 'page1')
     # create a new page object in pages/dir/subdir/
     page_object.new_page_object(testdir_fixture['path'],
                                 project, ['dir', 'subdir'],
                                 'page2',
                                 add_parents=True)
     base_path = os.path.join(testdir_fixture['path'], 'projects', project,
                              'pages')
     dotted_files = utils.get_files_in_directory_dot_path(base_path)
     assert 'page1' in dotted_files
     assert 'dir.subdir.page2' in dotted_files
     assert len(dotted_files) == 2
Ejemplo n.º 11
0
    def test__create_execution_directory_is_suite(self, testdir_fixture):
        """Verify that create_execution_directory works as expected when 
        a not suite is passed on
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        timestamp = utils.get_timestamp()
        test_name = 'any_test_name_does_not_matter_2'
        suite_name = 'single_tests'
        is_suite = False

        start_execution._create_execution_directory(root_path, project,
                                                    timestamp, test_name,
                                                    suite_name, is_suite)

        expected_path = os.path.join(root_path, 'projects', project,
                                     'reports', 'single_tests', test_name, timestamp)
        path_exists = os.path.isdir(expected_path)
        assert path_exists
Ejemplo n.º 12
0
    def test__create_execution_directory_is_suite(self, testdir_fixture):
        """Verify that create_execution_directory works as expected when 
        a not suite is passed on
        """
        root_path = testdir_fixture['path']
        project = create_random_project(root_path)
        timestamp = utils.get_timestamp()
        test_name = 'any_test_name_does_not_matter_2'
        suite_name = 'single_tests'
        is_suite = False

        start_execution._create_execution_directory(root_path, project,
                                                    timestamp, test_name,
                                                    suite_name, is_suite)

        expected_path = os.path.join(root_path, 'projects', project, 'reports',
                                     'single_tests', test_name, timestamp)
        path_exists = os.path.isdir(expected_path)
        assert path_exists
Ejemplo n.º 13
0
 def test_get_files_in_directory_dot_path(self, testdir_fixture):
     project = helper_functions.create_random_project(testdir_fixture['path'])
     # create a new page object in pages folder
     page_object.new_page_object(testdir_fixture['path'],
                                 project,
                                 [],
                                 'page1')
     # create a new page object in pages/dir/subdir/
     page_object.new_page_object(testdir_fixture['path'],
                                 project,
                                 ['dir', 'subdir'],
                                 'page2',
                                 add_parents=True)
     base_path = os.path.join(testdir_fixture['path'],
                              'projects',
                              project,
                              'pages')
     dotted_files = utils.get_files_in_directory_dot_path(base_path)
     assert 'page1' in dotted_files
     assert 'dir.subdir.page2' in dotted_files
     assert len(dotted_files) == 2