コード例 #1
0
    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_globals.xml")
        json_ref_path = os.path.join(data_path, "./data/test_globals_1.json")
        table_mapper = TableMapper("Results"
                             , votable_path
                             , json_inst_dict=DictUtils.read_dict_from_file(json_ref_path))
        table_mapper.resolve_refs_and_values(resolve_refs=True)

        #print(DictUtils.get_pretty_json(table_mapper.json["MODEL_INSTANCE"]["TABLE_MAPPING"]["my:other.role"]))
        self.assertDictEqual(table_mapper.json["MODEL_INSTANCE"]["TABLE_MAPPING"]["Results"]["my:other.role"]
                             ,{
                              "@ID": "TestParamRef",
                              "@dmtype": "Whatever",
                              "coords:whatever": {
                                "@dmtype": "coords:StdRefLocation",
                                "coords:StdRefLocation.position": {
                                  "@dmtype": "ivoa:string",
                                  "@ref": "param_ref",
                                  "@value": "param_value"
                                }
                              }
                            } 
                             , "")
コード例 #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"],
            "=======")
コード例 #3
0
    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")
        table_mapper = TableMapper("Results"
                             , votable_path
                             , json_inst_dict=DictUtils.read_dict_from_file(json_ref_path))
        table_mapper.resolve_refs_and_values()

        self.assertListEqual([*table_mapper.table_iterators], ['meas:Error.statError'], "")
        self.assertDictEqual(table_mapper.table_iterators['meas:Error.statError'].column_mapping.column_refs
                             , {'_poserr_148': {'parent_role': 'meas:Symmetrical.radius', 'role': 'ivoa:RealQuantity.value', 'index': None, 'field': None}}
                             , "")
        
        table_mapper.map_columns()
        self.assertDictEqual(table_mapper.table_iterators['meas:Error.statError'].column_mapping.column_ids
                             , {0: {'name': 'oidsaada', 'ref': None, 'id': '_poserr_148'}}
                             , "")
        self.assertEqual(table_mapper.table_iterators['meas:Error.statError'].row_filter.__repr__()
                             , "Row filter NoName key=_poserr_148 value=2 col=-1"
                             , "")

        self.assertListEqual(table_mapper.get_flatten_data_head()
                         ,['meas:Symmetrical.radius(ivoa:RealQuantity.value) [col#0 _poserr_148]'],""),
        cpt=2
        while True:
            inst = table_mapper._get_next_flatten_row()
            if inst != None:
                self.assertListEqual(inst, [cpt], "")
                cpt += 1
            else:
                break
        table_mapper.rewind()
        cpt=2
        while True:
            inst = table_mapper._get_next_row_instance()
            if inst != None:
                self.assertDictEqual(inst
                                     , {
                                      "@dmtype": "meas:Symmetrical",
                                      "meas:Symmetrical.radius": {
                                        "@dmtype": "ivoa:RealQuantity",
                                        "ivoa:Quantity.unit": {
                                          "@dmtype": "ivoa:Unit",
                                          "@value": "arcsec"
                                        },
                                        "ivoa:RealQuantity.value": {
                                          "@dmtype": "ivoa:real",
                                          "@ref": "_poserr_148",
                                          "@value": cpt
                                        }
                                      }
                                    }
                                     , "")
                cpt+=1
            else:
                break
コード例 #4
0
    def test_22(self):
        if self.populated is False:
            self.vodml_instance.populate_templates()
            self.vodml_instance.connect_join_iterators()
            self.populated = True
        table_mapper = self.vodml_instance.table_mappers["Results"]
        full_dict = table_mapper.get_full_instance()

        #
        #print(DictUtils.get_pretty_json(full_dict))
        self.assertDictEqual(full_dict, DictUtils.read_dict_from_file(self.json_ref_path), "")
コード例 #5
0
 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),
                          "")
コード例 #6
0
    def test_21(self):
        self.json_ref_path = os.path.join(
            self.data_path, "./data/test_vodml_instance_21.json")
        if self.populated is False:
            self.vodml_instance.populate_templates()
            self.vodml_instance.connect_join_iterators()
            self.populated = True
        table_mapper = self.vodml_instance.table_mappers["OtherResults"]
        full_dict = table_mapper.get_full_instance()

        #print(DictUtils.get_pretty_json(full_dict))
        self.assertDictEqual(full_dict,
                             DictUtils.read_dict_from_file(self.json_ref_path),
                             "")
コード例 #7
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), "=======")
コード例 #8
0
    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),
                             "=======")
コード例 #9
0
    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),
                             "=======")
コード例 #10
0
    def test_1(self):

        #print(DictUtils.get_pretty_json(self.vodml_instance.json_view))
        self.assertDictEqual(self.vodml_instance.json_view,
                             DictUtils.read_dict_from_file(self.json_ref_path),
                             "=======")