Example #1
0
    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"],
            "=======")
Example #2
0
 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
    def test_1(self):
        data_path = os.path.dirname(os.path.realpath(__file__))
        votable_path = os.path.join(data_path, "./data/test_composition.xml")
        json_ref_path = os.path.join(data_path,
                                     "./data/test_composition_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_compositions("COLLECTION")

        #print(DictUtils.get_pretty_json(builder.json["VODML"]["TEMPLATES"]))
        self.assertDictEqual(builder.json["VODML"]["TEMPLATES"],
                             DictUtils.read_dict_from_file(json_ref_path),
                             "=======")
Example #4
0
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),
                             "=======")
Example #6
0
    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):
        data_path = os.path.dirname(os.path.realpath(__file__))
        votable_path = os.path.join(data_path, "./data/test_globals.xml")
        json_ref_path = os.path.join(data_path, "./data/test_globals_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_elements("INSTANCE")
        builder.revert_elements("ATTRIBUTE")

        #print(DictUtils.get_pretty_json(builder.json))
        self.assertDictEqual(
            builder.json["MODEL_INSTANCE"]["GLOBALS"],
            DictUtils.read_dict_from_file(json_ref_path)["MODEL_INSTANCE"]
            ["GLOBALS"], "=======")
Example #8
0
    def _build_instance(self):
        '''
        Translate the VODML block into dict
        '''
        builder = JsonMappingBuilder(json_dict=self.json_block)

        builder.revert_sets("GLOBALS",
                                         default_key='globals')
        #self.builder.revert_compositions("COLLECTION")
        builder.revert_sets("TEMPLATES",
                                         default_key='root')
        builder.revert_array()
        builder.revert_compositions("COLLECTION")
        builder.revert_elements("INSTANCE")
        builder.revert_elements("ATTRIBUTE")
        builder.revert_elements("MODEL")

        self.json_vodml_block = builder.json
        print(DictUtils.get_pretty_json(self.json_vodml_block))
        logger.info("JSON VODML block built")