Exemple #1
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)
Exemple #2
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"],
            "=======")
Exemple #3
0
 def build_json_view(self):
     logger.info("Extracting the MODEL_INSTANCE block")
     instanceFromVotable = InstanceFromVotable(self.votable_path)
     instanceFromVotable._extract_vodml_block()
     logger.info("Validating the MODEL_INSTANCE block")
     instanceFromVotable._validate_vodml_block()
     logger.info("Extracting the raw JSON block")
     self.json_view = instanceFromVotable.json_block
Exemple #4
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)
Exemple #5
0
 def test_1(self):
     votable_path = os.path.dirname(os.path.realpath(__file__))
     votable_path = os.path.join(votable_path, "./data/test_instance.xml")
     json_ref_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "./data/test_instance_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["VODML"]["TEMPLATES"]))
     self.assertDictEqual(builder.json["VODML"]["TEMPLATES"], DictUtils.read_dict_from_file(json_ref_path), "=======")
    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["MODEL_INSTANCE"]["TABLE_MAPPING"]))
        self.assertDictEqual(builder.json["MODEL_INSTANCE"]["TABLE_MAPPING"],
                             DictUtils.read_dict_from_file(json_ref_path),
                             "=======")
    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),
                             "=======")