Example #1
0
def get_suite_test_cases(workspace, project, suite):
    '''Return a list with all the test cases of a given suite'''
    tests = []
    module_name = 'projects.{0}.suites.{1}'.format(project, suite)
    suite_module = importlib.import_module(module_name, package=None)
    if '*' in suite_module.tests:
        path = os.path.join(workspace, 'projects', project, 'tests')
        tests = utils.get_files_in_directory_dot_path(path)
    else:
        for test in suite_module.tests:
            if test[-1] == '*':
                this_dir = os.path.join(test[:-2])
                path = os.path.join(workspace, 'projects', project, 'tests',
                                    this_dir)
                this_dir_tests = utils.get_files_in_directory_dot_path(path)
                this_dir_tests = [
                    '{}.{}'.format(this_dir, x) for x in this_dir_tests
                ]
                tests = tests + this_dir_tests
            else:
                tests.append(test)
    return tests
Example #2
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
Example #3
0
 def test_get_files_in_directory_dot_path(self, project_fixture, test_directory_fixture):
     # create a new page object in pages folder
     page_object.new_page_object(test_directory_fixture['full_path'],
                                 project_fixture['project_name'],
                                 [],
                                 'page1')
     # create a new page object in pages/dir/subdir/
     page_object.new_page_object(test_directory_fixture['full_path'],
                                 project_fixture['project_name'],
                                 ['dir', 'subdir'],
                                 'page2')
     base_path = os.path.join(test_directory_fixture['full_path'],
                              'projects',
                              project_fixture['project_name'],
                              '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
Example #4
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
Example #5
0
def get_page_objects():
    if request.method == 'POST':
        project = request.form['project']
        path = os.path.join(root_path, 'projects', project, 'pages')
        page_objects = utils.get_files_in_directory_dot_path(path)
        return json.dumps(page_objects)
Example #6
0
def is_page_object(parameter, root_path, project):
    # identify if a parameter is a page object
    path = os.path.join(root_path, 'projects', project, 'pages')
    page_objects = utils.get_files_in_directory_dot_path(path)
    page_object_chain = '.'.join(parameter.split('.')[:-1])
    return bool(page_object_chain in page_objects)
Example #7
0
def is_page_object(parameter, root_path, project):
    # identify if a parameter is a page object
    path = os.path.join(root_path, 'projects', project, 'pages')
    page_objects = utils.get_files_in_directory_dot_path(path)
    page_object_chain = '.'.join(parameter.split('.')[:-1])
    return bool(page_object_chain in page_objects)
Example #8
0
def get_page_objects():
    if request.method == 'POST':
        project = request.form['project']
        path = os.path.join(root_path, 'projects', project, 'pages')
        page_objects = utils.get_files_in_directory_dot_path(path)
        return json.dumps(page_objects)