def mock_structure(file_path=None, current_file=None, old_file=None): # type: (Optional[str], Optional[dict], Optional[dict]) -> StructureValidator with patch.object(StructureValidator, '__init__', lambda a, b: None): structure = StructureValidator(file_path) structure.is_valid = True structure.scheme_name = 'integration' structure.file_path = file_path structure.current_file = current_file structure.old_file = old_file return structure
def test_is_valid_name_sanity(self, current_file, answer): with patch.object(StructureValidator, '__init__', lambda a, b: None): structure = StructureValidator("") structure.current_file = current_file structure.old_file = None structure.file_path = "random_path" structure.is_valid = True validator = IncidentFieldValidator(structure) validator.current_file = current_file assert validator.is_valid_name() is answer assert validator.is_valid_file() is answer
def get_validator(current_file=None, old_file=None, file_path=""): with patch.object(StructureValidator, '__init__', lambda a, b: None): structure = StructureValidator("") structure.current_file = current_file structure.old_file = old_file structure.file_path = file_path structure.is_valid = True validator = ScriptValidator(structure) validator.old_script = old_file validator.current_script = current_file return validator
def test_fromversion_update_validation_yml_structure( self, path, old_file_path, answer): validator = StructureValidator(file_path=path) with open(old_file_path) as f: validator.old_file = yaml.safe_load(f) assert validator.is_valid_fromversion_on_modified() is answer
def test_is_id_modified(self, current_file, old_file, answer, error): validator = StructureValidator(file_path=current_file) with open(old_file) as f: validator.old_file = yaml.safe_load(f) assert validator.is_id_modified() is answer, error