def load_and_parse_schema(eq_id, form_type): """ Use the schema loader to get the schema from disk. Then use the parse to construct the object schema :param eq_id: the id of the questionnaire :param form_type: the form type :return: (json, schema) # Tuple of json and schema object from schema file """ # load the schema json_schema = load_schema(eq_id, form_type) if json_schema: parser = SchemaParserFactory.create_parser(json_schema) schema = parser.parse() return json_schema, schema else: return None
def load_and_parse_schema(eq_id, form_type, language_code): """ Use the schema loader to get the schema from disk. Then use the parse to construct the object schema :param eq_id: the id of the questionnaire :param form_type: the form type :return: (json, schema) # Tuple of json and schema object from schema file """ # load the schema json_schema = load_schema(eq_id, form_type, language_code) if json_schema: parser = SchemaParser(json_schema) schema = parser.parse() return json_schema, schema else: raise ValueError("No schema available")
def test_load_schema_with_different_form_type(self): self.assertIsNotNone(load_schema("1", "0205"))
def test_load_schema(self): self.assertIsNotNone(load_schema("1", "0203"))
def test_load_schema_with_language_code(self): self.assertIsNotNone(load_schema("test", "language", "cy"))
def test_load_schema_with_passing_default_language_code(self): self.assertIsNotNone(load_schema("test", "language", "en"))
def test_load_schema_with_invalid_eq_id(self): self.assertIsNone(load_schema("99", "0205"))
def test_load_schema_with_invalid_form_type(self): self.assertIsNone(load_schema("1", "0309"))