def test_invalid_json(self, value): input_filepath, error_msg = value input_filepath = os.path.join(os.path.dirname(__file__), input_filepath) with self.assertRaises(jsonschema.exceptions.ValidationError) as cm: utils.validate_json_schema(input_filepath, self.valid_filepath) self.assertTrue(error_msg in cm.exception.args[0])
def visit_ontology_imports( self, import_path: str, visited_paths: Optional[Dict[str, bool]] = None, rec_visited_paths: Optional[Dict[str, bool]] = None, ) -> Optional[Tuple[str, Dict[str, bool], Dict[str, bool]]]: # Initialize the visited dicts when the function is called for the # first time. if visited_paths is None: visited_paths = defaultdict(lambda: False) if rec_visited_paths is None: rec_visited_paths = defaultdict(lambda: False) # Check for import cycles if rec_visited_paths[import_path]: raise OntologyAlreadyGeneratedException( f"Ontology corresponding to {import_path} already " f"generated, cycles not permitted, aborting") # If the ontology is already generated, need not generate it again if visited_paths[import_path]: return None # Add the json_file path to the visited dictionaries visited_paths[import_path] = True rec_visited_paths[import_path] = True # Validate and load the ontology specification. try: utils.validate_json_schema(import_path) except Exception as exception: if type(exception).__name__.split( ".")[0] == jsonschema.__name__ and hasattr( exception, "message"): raise OntologySpecValidationError() from exception raise return import_path, visited_paths, rec_visited_paths
def test_valid_json(self, input_filepath): input_filepath = os.path.join(os.path.dirname(__file__), input_filepath) utils.validate_json_schema(input_filepath, self.valid_filepath)
def test_valid_json(self, input_filepath): input_filepath = os.path.join(self.spec_dir, input_filepath) utils.validate_json_schema(input_filepath)
def test_valid_json(self, input_filepath): utils.validate_json_schema(input_filepath, self.valid_filepath)