def delete_element(): if request.method == 'POST': project = request.form['project'] elem_type = request.form['elemType'] full_path = request.form['fullPath'] errors = utils.delete_element(root_path, project, elem_type, full_path) return json.dumps(errors)
def test_delete_suites(self, project_function): _, project = project_function.activate() suite.new_suite(project, [], 'suite1') suite.new_suite(project, [], 'suite2') errors = utils.delete_element(project, 'suite', 'suite1') assert errors == [] path = os.path.join(project_function.path, 'suites', 'suite1.py') assert not os.path.exists(path) path = os.path.join(project_function.path, 'suites', 'suite2.py') assert os.path.exists(path)
def test_delete_pages(self, project_function): _, project = project_function.activate() page_object.new_page_object(project, [], 'page1') page_object.new_page_object(project, [], 'page2') errors = utils.delete_element(project, 'page', 'page1') assert errors == [] path = os.path.join(project_function.path, 'pages', 'page1.py') assert not os.path.exists(path) path = os.path.join(project_function.path, 'pages', 'page2.py') assert os.path.exists(path)
def test_delete_tests(self, project_function): _, project = project_function.activate() test_case.new_test_case(project, ['subdir1'], 'test1') test_case.new_test_case(project, ['subdir1'], 'test2') test_case.new_test_case(project, [], 'test3') test_case.new_test_case(project, [], 'test4') errors_one = utils.delete_element(project, 'test', 'subdir1.test1') errors_two = utils.delete_element(project, 'test', 'test3') assert errors_one == [] assert errors_two == [] path = os.path.join(project_function.path, 'tests', 'subdir1', 'test1.py') assert not os.path.exists(path) path = os.path.join(project_function.path, 'tests', 'test3.py') assert not os.path.exists(path) path = os.path.join(project_function.path, 'tests', 'subdir1', 'test2.py') assert os.path.exists(path) path = os.path.join(project_function.path, 'tests', 'test4.py') assert os.path.exists(path)
def test_delete_tests(self, project_function): testdir = project_function['testdir'] project = project_function['name'] os.chdir(testdir) test_case.new_test_case(testdir, project, ['subdir1'], 'test1') test_case.new_test_case(testdir, project, ['subdir1'], 'test2') test_case.new_test_case(testdir, project, [], 'test3') test_case.new_test_case(testdir, project, [], 'test4') errors_one = utils.delete_element(testdir, project, 'test', 'subdir1.test1') errors_two = utils.delete_element(testdir, project, 'test', 'test3') assert errors_one == [] assert errors_two == [] path = os.path.join(testdir, 'projects', project, 'tests', 'subdir1', 'test1.py') assert not os.path.exists(path) path = os.path.join(testdir, 'projects', project, 'tests', 'test3.py') assert not os.path.exists(path) path = os.path.join(testdir, 'projects', project, 'tests', 'subdir1', 'test2.py') assert os.path.exists(path) path = os.path.join(testdir, 'projects', project, 'tests', 'test4.py') assert os.path.exists(path)
def test_delete_suites(self, project_function): testdir = project_function.testdir project = project_function.name os.chdir(testdir) suite.new_suite(testdir, project, [], 'suite1') suite.new_suite(testdir, project, [], 'suite2') errors = utils.delete_element(testdir, project, 'suite', 'suite1') assert errors == [] path = os.path.join(project_function.path, 'suites', 'suite1.py') assert not os.path.exists(path) path = os.path.join(project_function.path, 'suites', 'suite2.py') assert os.path.exists(path)
def test_delete_pages(self, project_function): testdir = project_function['testdir'] project = project_function['name'] os.chdir(testdir) page_object.new_page_object(testdir, project, [], 'page1') page_object.new_page_object(testdir, project, [], 'page2') errors = utils.delete_element(testdir, project, 'page', 'page1') assert errors == [] path = os.path.join(testdir, 'projects', project, 'pages', 'page1.py') assert not os.path.exists(path) path = os.path.join(testdir, 'projects', project, 'pages', 'page2.py') assert os.path.exists(path)
def test_delete_test_with_data(self, project_function): """"test that when a test is deleted the data files are deleted as well """ _, project = project_function.activate() test_case.new_test_case(project, [], 'test1') data_path_data = os.path.join(project_function.path, 'data', 'test1.csv') os.makedirs(os.path.dirname(data_path_data)) open(data_path_data, 'x').close() data_path_tests = os.path.join(project_function.path, 'tests', 'test1.csv') open(data_path_tests, 'x').close() errors = utils.delete_element(project, 'test', 'test1') assert errors == [] test_path = os.path.join(project_function.path, 'tests', 'test1.py') assert not os.path.exists(test_path) assert not os.path.exists(data_path_data) assert not os.path.exists(data_path_tests)
def test_delete_element_does_not_exist(self, project_function): _, project = project_function.activate() errors = utils.delete_element(project, 'suite', 'suite1') assert errors == ['File suite1 does not exist']
def test_delete_element_does_not_exist(self, project_function): testdir = project_function.testdir project = project_function.name os.chdir(testdir) errors = utils.delete_element(testdir, project, 'suite', 'suite1') assert errors == ['File suite1 does not exist']