def test_2(self): self.maxDiff = None data_path = os.path.dirname(os.path.realpath(__file__)) votable_path = os.path.join(data_path, "./data/test_multi_templates.xml") json_ref_path = os.path.join(data_path, "./data/test_multi_templates.json") logger.info("extract vodml block from %s", votable_path) instanceFromVotable = InstanceFromVotable(votable_path) instanceFromVotable._extract_vodml_block() instanceFromVotable._validate_vodml_block() builder = JsonMappingBuilder(json_dict=instanceFromVotable.json_block) builder.revert_compositions("COLLECTION") builder.revert_templates() builder.revert_elements("INSTANCE") builder.revert_elements("ATTRIBUTE") #print(DictUtils.get_pretty_json(builder.json)) self.assertDictEqual( builder.json["MODEL_INSTANCE"], DictUtils.read_dict_from_file(json_ref_path)["MODEL_INSTANCE"], "=======")
def build_json_mapping(self): logger.info("Formating the JSON view") builder = JsonMappingBuilder(json_dict=self.json_view) builder.revert_compositions("COLLECTION") builder.revert_templates() builder.revert_elements("INSTANCE") builder.revert_elements("ATTRIBUTE") self.json_view = builder.json
class TestInstanceFullFeature(unittest.TestCase): def test_1(self): self.json_ref_path = os.path.join( self.data_path, "./data/test_inst_fullfeature_1.json") self.maxDiff = None self.table_mapper.resolve_refs_and_values() self.table_mapper.map_columns() full_dict = self.table_mapper.get_full_instance() #print(DictUtils.get_pretty_json(full_dict)) #print( DictUtils.read_dict_from_file(json_ref_path)) self.assertDictEqual(full_dict, DictUtils.read_dict_from_file(self.json_ref_path), "") def test_2(self): self.json_ref_path = os.path.join( self.data_path, "./data/test_inst_fullfeature_2.json") self.maxDiff = None self.table_mapper.resolve_refs_and_values() self.table_mapper.map_columns() full_dict = self.table_mapper.get_full_instance(resolve_refs=True) #print(DictUtils.get_pretty_json(full_dict)) #print( DictUtils.read_dict_from_file(json_ref_path)) self.assertDictEqual(full_dict, DictUtils.read_dict_from_file(self.json_ref_path), "") def setUp(self): self.data_path = os.path.dirname(os.path.realpath(__file__)) self.votable_path = os.path.join(self.data_path, "./data/test_inst_fullfeature.xml") self.json_ref_path = "" self.instanceFromVotable = InstanceFromVotable(self.votable_path) self.instanceFromVotable._extract_vodml_block() self.instanceFromVotable._validate_vodml_block() self.builder = JsonMappingBuilder( json_dict=self.instanceFromVotable.json_block) #builder.revert_array() self.builder.revert_compositions("COLLECTION") self.builder.revert_templates() self.builder.revert_elements("INSTANCE") self.builder.revert_elements("ATTRIBUTE") #print(DictUtils.get_pretty_json(builder.json)) self.table_mapper = TableMapper("Results", self.votable_path, json_inst_dict=self.builder.json)
def test_1(self): self.maxDiff = None data_path = os.path.dirname(os.path.realpath(__file__)) votable_path = os.path.join(data_path, "./data/test_filter.xml") json_ref_path = os.path.join(data_path, "./data/test_filter_1.json") logger.info("extract vodml block from %s", votable_path) instanceFromVotable = InstanceFromVotable(votable_path) instanceFromVotable._extract_vodml_block() instanceFromVotable._validate_vodml_block() builder = JsonMappingBuilder(json_dict=instanceFromVotable.json_block) #builder.revert_array() builder.revert_compositions("COLLECTION") builder.revert_templates() builder.revert_elements("INSTANCE") builder.revert_elements("ATTRIBUTE") self.assertDictEqual(json.loads(json.dumps(builder.json)), DictUtils.read_dict_from_file(json_ref_path), "=======")