Ticket #2093: test_paths.diff

File test_paths.diff, 2.2 KB (added by oubiwann, 8 years ago)

diff for new test_paths with authority tests

  • twisted/test/test_paths.py

    old new  
    425425        self.assertEquals(str(self.path.here()), 'http://example.com/foo/') 
    426426        self.assertEquals(str(self.path.child('').here()), 'http://example.com/foo/bar/') 
    427427 
     428class URLPathAuthTestCase(unittest.TestCase): 
     429    def setUp(self): 
     430        self.path = urlpath.URLPath.fromString("http://alice:asecret@example.com/foo/bar?yes=no&no=yes#footer") 
     431 
     432    def testStringConversion(self): 
     433        self.assertEquals(str(self.path), "http://alice:asecret@example.com/foo/bar?yes=no&no=yes#footer") 
     434         
     435    def testChildString(self): 
     436        self.assertEquals(str(self.path.child('hello')), "http://alice:asecret@example.com/foo/bar/hello") 
     437        self.assertEquals(str(self.path.child('hello').child('')), "http://alice:asecret@example.com/foo/bar/hello/") 
     438         
     439    def testSiblingString(self): 
     440        self.assertEquals(str(self.path.sibling('baz')), 'http://alice:asecret@example.com/foo/baz') 
     441 
     442        # The sibling of http://example.com/foo/bar/ 
     443        #     is http://example.comf/foo/bar/baz 
     444        # because really we are constructing a sibling of 
     445        # http://example.com/foo/bar/index.html 
     446        self.assertEquals(str(self.path.child('').sibling('baz')), 'http://alice:asecret@example.com/foo/bar/baz') 
     447         
     448    def testParentString(self): 
     449        # parent should be equivalent to '..' 
     450        # 'foo' is the current directory, '/' is the parent directory 
     451        self.assertEquals(str(self.path.parent()), 'http://alice:asecret@example.com/') 
     452        self.assertEquals(str(self.path.child('').parent()), 'http://alice:asecret@example.com/foo/') 
     453        self.assertEquals(str(self.path.child('baz').parent()), 'http://alice:asecret@example.com/foo/') 
     454        self.assertEquals(str(self.path.parent().parent().parent().parent().parent()), 'http://alice:asecret@example.com/') 
     455 
     456    def testHereString(self): 
     457        # here should be equivalent to '.' 
     458        self.assertEquals(str(self.path.here()), 'http://alice:asecret@example.com/foo/') 
     459        self.assertEquals(str(self.path.child('').here()), 'http://alice:asecret@example.com/foo/bar/')