def testStoresFragment(self): """WalkerBase stores the fragment portion of a supporting URL.""" WalkerBase.FRAGMENTS = True try: w = WalkerBase("http://localhost/#foo") self.assertEqual(w.fragment, "foo") finally: WalkerBase.FRAGMENTS = False
def testNoUsername(self): """WalkerBase stores None when there is no username.""" w = WalkerBase("ftp://localhost/") self.assertEqual(w.user, None)
def testUnescapesHost(self): """WalkerBase unescapes the host portion.""" w = WalkerBase("ftp://local%40host/") self.assertEqual(w.host, "local@host")
def testNoScheme(self): """WalkerBase works when given a URL with no scheme.""" w = WalkerBase("/") self.assertEqual(w.host, "")
def testSetsHost(self): """WalkerBase sets the host property.""" w = WalkerBase("ftp://localhost/") self.assertEqual(w.host, "localhost")
def testSetsScheme(self): """WalkerBase sets the scheme property.""" w = WalkerBase("ftp://localhost/") self.assertEqual(w.scheme, "ftp")
def testUnescapesPassword(self): """WalkerBase unescapes the password portion.""" w = WalkerBase("ftp://*****:*****@localhost/") self.assertEqual(w.user, "scott") self.assertEqual(w.passwd, "wibble wobble") self.assertEqual(w.host, "localhost")
def testNoPassword(self): """WalkerBase stores None when there is no password.""" w = WalkerBase("ftp://scott@localhost/") self.assertEqual(w.passwd, None)
def testCreatesDefaultLogger(self): """WalkerBase creates a default logger.""" w = WalkerBase("/") self.assertTrue(isinstance(w.log, logging.Logger))
def testUnescapesPath(self): """WalkerBase leaves the path escaped.""" w = WalkerBase("ftp://localhost/some%20thing/") self.assertEqual(w.path, "/some%20thing/")
def testStoresQuery(self): """WalkerBase stores the query portion of a supporting URL.""" w = WalkerBase("http://localhost/?foo") self.assertEqual(w.query, "foo")
def testAddsSlashToPath(self): """WalkerBase adds a trailing slash to path if ommitted.""" w = WalkerBase("ftp://localhost/path/to/something") self.assertEqual(w.path, "/path/to/something/")
def testPathInUrl(self): """WalkerBase stores the path portion of a complete URL.""" w = WalkerBase("ftp://localhost/path/to/something/") self.assertEqual(w.path, "/path/to/something/")
def testPathOnly(self): """WalkerBase stores the path if that's all there is.""" w = WalkerBase("/path/to/something/") self.assertEqual(w.path, "/path/to/something/")
def testUsername(self): """WalkerBase splits out the username from the host portion.""" w = WalkerBase("ftp://scott@localhost/") self.assertEqual(w.user, "scott") self.assertEqual(w.host, "localhost")
def testCreatesChildLogger(self): """WalkerBase creates a child logger if given a parent.""" parent = logging.getLogger("foo") w = WalkerBase("/", log_parent=parent) self.assertEqual(w.log.parent, parent)
def testUnescapesUsername(self): """WalkerBase unescapes the username portion.""" w = WalkerBase("ftp://scott%3awibble@localhost/") self.assertEqual(w.user, "scott:wibble") self.assertEqual(w.host, "localhost")
def testSetsBase(self): """WalkerBase sets the base property.""" w = WalkerBase("ftp://localhost/") self.assertEqual(w.base, "ftp://localhost/")
def testPassword(self): """WalkerBase splits out the password from the username.""" w = WalkerBase("ftp://*****:*****@localhost/") self.assertEqual(w.user, "scott") self.assertEqual(w.passwd, "wibble") self.assertEqual(w.host, "localhost")
def testCreatesDefaultLogger(self): """WalkerBase creates a default logger.""" from logging import Logger w = WalkerBase("/") self.failUnless(isinstance(w.log, Logger))