def test_duplicate_test_with_data_file(self, project_session, test_utils): """Assert when a test has a data file the data file is duplicated as well""" _, project = project_session.activate() test_name = test_utils.create_random_test(project) new_test_name = test_utils.random_string() data_path = os.path.splitext(Test(project, test_name).path)[0] + '.csv' with open(data_path, 'w+') as f: f.write('') new_data_path = os.path.splitext(test_module.Test(project, new_test_name).path)[0] + '.csv' test_module.duplicate_test(project, test_name, new_test_name) assert os.path.isfile(data_path) assert os.path.isfile(new_data_path)
def test_duplicate_test_invalid_name(self, project_session, test_utils): _, project = project_session.activate() test_name = test_utils.create_random_test(project) # invalid name new_test_name = 'new-name' errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == ['Only letters, numbers and underscores are allowed'] # empty name new_test_name = 'test.' errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == ['File name cannot be empty'] # empty directory new_test_name = 'test.' errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == ['File name cannot be empty']
def test_duplicate(): project = request.json['project'] test_name = request.json['fullPath'] new_test_name = request.json['newFileFullPath'] _verify_permissions(Permissions.STANDARD, project) errors = test_module.duplicate_test(project, test_name, new_test_name) return jsonify(errors)
def test_duplicate_test_dest_exists(self, project_session, test_utils): _, project = project_session.activate() test_one = test_utils.create_random_test(project) test_two = test_utils.create_random_test(project) errors = test_module.duplicate_test(project, test_one, test_two) assert errors == ['A test with that name already exists'] # to another folder test_one = test_utils.create_random_test(project) test_two = '{}.{}'.format(test_utils.random_string(), test_utils.random_string()) test_utils.create_test(project, test_two) errors = test_module.duplicate_test(project, test_one, test_two) assert errors == ['A test with that name already exists'] # to same name test_one = test_utils.create_random_test(project) test_utils.create_test(project, test_two) errors = test_module.duplicate_test(project, test_one, test_one) assert errors == ['New test name cannot be the same as the original']
def test_duplicate_test(self, project_session, test_utils): _, project = project_session.activate() test_name = test_utils.create_random_test(project) new_test_name = test_utils.random_string() errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == [] tests = Project(project).tests() assert test_name in tests assert new_test_name in tests
def test_duplicate_test(self, project_session, test_utils): _, project = project_session.activate() # in root folder test_name = test_utils.create_random_test(project) new_test_name = test_utils.random_string() errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == [] tests = Project(project).tests() assert test_name in tests assert new_test_name in tests # in folder dir = test_utils.random_string() name = test_utils.random_string() test_name = '{}.{}'.format(dir, name) test_utils.create_test(project, test_name) new_name = test_utils.random_string() new_test_name = '{}.{}'.format(dir, new_name) errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == [] tests = Project(project).tests() assert test_name in tests assert new_test_name in tests
def test_duplicate_test_same_name(self, project_session, test_utils): _, project = project_session.activate() test_name = test_utils.create_random_test(project) errors = test_module.duplicate_test(project, test_name, test_name) assert errors == ['New test name cannot be the same as the original']
def test_duplicate_test_error(self, project_session, test_utils): _, project = project_session.activate() test_name = test_utils.create_random_test(project) new_test_name = 'new-name' errors = test_module.duplicate_test(project, test_name, new_test_name) assert errors == ['Only letters, numbers and underscores are allowed']
def test_duplicate_test_name_already_exists(self, project_session, test_utils): _, project = project_session.activate() test_name = test_utils.create_random_test(project) test_name_two = test_utils.create_random_test(project) errors = test_module.duplicate_test(project, test_name, test_name_two) assert errors == ['A test with that name already exists']