Beispiel #1
0
    def testExampleName(self):
        # Adapted from
        # https://tools.ietf.org/id/draft-soilandreyes-arcp-02.html#rfc.appendix.A.7
        self.assertEqual("arcp://name,gallery.example.org/",
                         generate.arcp_name("gallery.example.org"))
        new_photos = generate.arcp_name("gallery.example.org", "/photos/",
                                        "New")

        self.assertEqual("arcp://name,gallery.example.org/photos/?New",
                         new_photos)
        photo = generate.arcp_name("gallery.example.org", "/photos/137")
        self.assertEqual("arcp://name,gallery.example.org/photos/137", photo)

        template = "arcp://name,messaging.example.com/share;{*uri};{*redirect}"
        u = template.replace("{*uri}", photo).replace("{*redirect}",
                                                      new_photos)

        # TODO: Should arcp_name support
        path = "/share;%s;%s" % (photo, new_photos)
        self.assertEqual(u, generate.arcp_name("messaging.example.com", path))
Beispiel #2
0
 def testEmptyName(self):
     # empty name is valid by the spec (TODO: should it be?)
     self.assertEqual("arcp://name,/", generate.arcp_name(""))
Beispiel #3
0
 def testInvalidName(self):
     with self.assertRaises(Exception):
         generate.arcp_name("example com")
Beispiel #4
0
 def testNamePathQueryHash(self):
     self.assertEqual(
         "arcp://name,app.example.org/msgs/1?a=b&c=d#frag",
         generate.arcp_name("app.example.org", "/msgs/1", "a=b&c=d",
                            "frag"))
Beispiel #5
0
 def testNameHash(self):
     self.assertEqual(
         "arcp://name,app.example.org/#frag",
         generate.arcp_name("app.example.org", fragment="frag"))
Beispiel #6
0
 def testNameQuery(self):
     self.assertEqual("arcp://name,app.example.org/?q=a",
                      generate.arcp_name("app.example.org", query="q=a"))
Beispiel #7
0
 def testNamePath(self):
     self.assertEqual("arcp://name,app.example.org/msgs/1",
                      generate.arcp_name("app.example.org", "/msgs/1"))