def test_from_future(self):
        # any URI type that we don't recognize should be treated as unknown
        future_uri = "I am a URI from the future. Whatever you do, don't "
        u = uri.from_string(future_uri)
        self.failUnless(isinstance(u, uri.UnknownURI))
        self.failUnlessReallyEqual(u.to_string(), future_uri)
        self.failUnless(u.get_readonly() is None)
        self.failUnless(u.get_error() is None)

        u2 = uri.UnknownURI(future_uri, error=CapConstraintError("..."))
        self.failUnlessReallyEqual(u.to_string(), future_uri)
        self.failUnless(u2.get_readonly() is None)
        self.failUnless(isinstance(u2.get_error(), CapConstraintError))

        # Future caps might have non-ASCII chars in them. (Or maybe not, who can tell about the future?)
        future_uri = u"I am a cap from the \u263A future. Whatever you ".encode(
            'utf-8')
        u = uri.from_string(future_uri)
        self.failUnless(isinstance(u, uri.UnknownURI))
        self.failUnlessReallyEqual(u.to_string(), future_uri)
        self.failUnless(u.get_readonly() is None)
        self.failUnless(u.get_error() is None)

        u2 = uri.UnknownURI(future_uri, error=CapConstraintError("..."))
        self.failUnlessReallyEqual(u.to_string(), future_uri)
        self.failUnless(u2.get_readonly() is None)
        self.failUnless(isinstance(u2.get_error(), CapConstraintError))
 def test_compare(self):
     lit1 = uri.LiteralFileURI("some data")
     fileURI = 'URI:CHK:f5ahxa25t4qkktywz6teyfvcx4:opuioq7tj2y6idzfp6cazehtmgs5fdcebcz3cygrxyydvcozrmeq:3:10:345834'
     chk1 = uri.CHKFileURI.init_from_string(fileURI)
     chk2 = uri.CHKFileURI.init_from_string(fileURI)
     unk = uri.UnknownURI("lafs://from_the_future")
     self.failIfEqual(lit1, chk1)
     self.failUnlessReallyEqual(chk1, chk2)
     self.failIfEqual(chk1, "not actually a URI")
     # these should be hashable too
     s = set([lit1, chk1, chk2, unk])
     self.failUnlessReallyEqual(len(s), 3)  # since chk1==chk2
Exemple #3
0
 def get_readcap(self):
     return uri.UnknownURI(self.ro_uri)
Exemple #4
0
 def get_cap(self):
     return uri.UnknownURI(self.rw_uri or self.ro_uri)