Ejemplo n.º 1
0
    def test_ivoid2_examples(self):
        # Here we check all the examples given in \S2.3 of the IVOA
        # Identifiers Version 2.0 spec.
        for auth in ["nasa.heasarc", "n_1a.alph-0.02", "123"]:
            self._good_parse(auth, "/rsrc", "local")
        for auth in ["a2", "_temporary.id", "DAT%41", "de!uni-hd!physics#ari"]:
            self._bad_parse(auth, "/rsrc", "local")

        for rsrc in ["", "/reskey", "/user/STScI_1/1a-7z.u"]:
            self._good_parse("auth", rsrc, "local")
        for rsrc in ["/", "/data/", "/data//other", "/data/c/../d", "/data!g-vo.org", "/user/M%fcller"]:
            self._bad_parse("auth", rsrc, "local")

        # This one is special, because we have no way to tell that
        # "ivo://authreskey#local" isn't a valid IVOID with no resource key.
        # We expect the parse to be wrong, and we can't do anything about it!
        self.assertNotEqual(parse_ivoid("ivo://authreskey#local"),
                                       ("auth", "reskey", "local"))
Ejemplo n.º 2
0
    def test_ivoid2_examples(self):
        # Here we check all the examples given in \S2.3 of the IVOA
        # Identifiers Version 2.0 spec.
        for auth in ["nasa.heasarc", "n_1a.alph-0.02", "123"]:
            self._good_parse(auth, "/rsrc", "local")
        for auth in ["a2", "_temporary.id", "DAT%41", "de!uni-hd!physics#ari"]:
            self._bad_parse(auth, "/rsrc", "local")

        for rsrc in ["", "/reskey", "/user/STScI_1/1a-7z.u"]:
            self._good_parse("auth", rsrc, "local")
        for rsrc in ["/", "/data/", "/data//other", "/data/c/../d", "/data!g-vo.org", "/user/M%fcller"]:
            self._bad_parse("auth", rsrc, "local")

        # This one is special, because we have no way to tell that
        # "ivo://authreskey#local" isn't a valid IVOID with no resource key.
        # We expect the parse to be wrong, and we can't do anything about it!
        self.assertNotEqual(parse_ivoid("ivo://authreskey#local"),
                                       ("auth", "reskey", "local"))
Ejemplo n.º 3
0
 def test_no_fragment(self):
     auth, rsrc = "authorityID", "/resourceKey"
     ivoid = "ivo://%s%s" % (auth, rsrc)
     self.assertEqual((auth, rsrc, ''), parse_ivoid(ivoid))
Ejemplo n.º 4
0
 def _good_parse(self, auth, rsrc, local):
     # IVOID should be parsed and inputs recovered.
     ivoid = self._build_ivoid(auth, rsrc, local)
     self.assertEqual(parse_ivoid(ivoid), (auth, rsrc, local))
Ejemplo n.º 5
0
 def __call__(self, event):
     # parse_ivoid() raises if whatever it is passed is unparseable.
     auth, rsrc, local_ID = parse_ivoid(event.element.attrib['ivorn'])
     if not local_ID:
         raise Exception("No per-event local ID")
Ejemplo n.º 6
0
 def test_no_fragment(self):
     auth, rsrc = "authorityID", "/resourceKey"
     ivoid = "ivo://%s%s" % (auth, rsrc)
     self.assertEqual((auth, rsrc, ''), parse_ivoid(ivoid))
Ejemplo n.º 7
0
 def _good_parse(self, auth, rsrc, local):
     # IVOID should be parsed and inputs recovered.
     ivoid = self._build_ivoid(auth, rsrc, local)
     self.assertEqual(parse_ivoid(ivoid), (auth, rsrc, local))
Ejemplo n.º 8
0
 def __call__(self, event):
     # parse_ivoid() raises if whatever it is passed is unparseable.
     auth, rsrc, local_ID = parse_ivoid(event.element.attrib['ivorn'])
     if not local_ID:
         raise Exception("No per-event local ID")