def testLocalhostExpandUser(self): urlparser = URLParser() logname = os.environ.get('LOGNAME') home = os.environ.get('HOME') self.assertEqual( urlparser.abspath('file://localhost/~%s/public' % logname), 'file://localhost%s/public' % home)
def testIdempotence(self): urlparser = URLParser() self.assertEqual( urlparser.to_ssh_url('[email protected]:var/dist/public'), '[email protected]:var/dist/public') self.assertEqual( urlparser.to_ssh_url('[email protected]:/var/dist/public'), '[email protected]:/var/dist/public')
def testSlashBeforeColon(self): urlparser = URLParser() self.assertEqual(urlparser.is_ssh_url('/foo:'), False)
def testSplitFile(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('file:///var/dist/public'), ('file', '', '', '/var/dist/public', '', ''))
def testSplitHttp(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('http://jarn.com/public'), ('http', '', 'jarn.com', '/public', '', ''))
def testSvnUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('svn://'), True)
def testSplitGit(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('git://jarn.com/public'), ('git', '', 'jarn.com', '/public', '', ''))
def testEmptyString(self): urlparser = URLParser() self.assertEqual(urlparser.is_url(''), False)
def testRelativeFileUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file:'), True)
def testSftp(self): urlparser = URLParser() self.assertEqual( urlparser.to_ssh_url('sftp://[email protected]/var/dist/public'), '[email protected]:/var/dist/public')
def testWhitespace(self): urlparser = URLParser() self.assertEqual( urlparser.is_ssh_url(' [email protected]:Jarn/jarn.mkrelease'), False)
def testBadUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_ssh_url('ssh'), False)
def testNonConsecutive(self): urlparser = URLParser() self.assertEqual(urlparser.is_ssh_url('f o:'), False)
def testNonAlphanumeric(self): urlparser = URLParser() self.assertEqual(urlparser.is_ssh_url('$&%:'), True)
def testColonOnly(self): urlparser = URLParser() self.assertEqual(urlparser.is_ssh_url(':'), False)
def testBadUrl(self): urlparser = URLParser() self.assertEqual( urlparser.to_ssh_url('https://[email protected]/var/dist/public'), 'https://[email protected]/var/dist/public')
def testNonFile(self): urlparser = URLParser() self.assertEqual(urlparser.abspath('svn://jarn.com/public'), 'svn://jarn.com/public')
def testHttpsUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('https://'), True)
def testBadScheme(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('ftp//'), False)
def testWhitespace(self): urlparser = URLParser() self.assertEqual( urlparser.to_ssh_url(' ssh://[email protected]/var/dist/public'), ' ssh://[email protected]/var/dist/public')
def testSplitSvn(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('svn://jarn.com/public'), ('svn', '', 'jarn.com', '/public', '', ''))
def testEmptyString(self): urlparser = URLParser() self.assertEqual(urlparser.to_ssh_url(''), '')
def testSplitRsync(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('rsync://jarn.com/public'), ('rsync', '', 'jarn.com', '/public', '', ''))
def testRelativeFile(self): urlparser = URLParser() cwd = os.getcwd() self.assertEqual(urlparser.abspath('file:var/dist/public'), 'file://%s/var/dist/public' % cwd)
def testSplitSsh(self): urlparser = URLParser() self.assertEqual( urlparser.urlsplit('ssh://[email protected]//hg/public'), ('ssh', 'stefan', 'jarn.com', '//hg/public', '', ''))
def testLocalhost(self): urlparser = URLParser() cwd = os.getcwd() self.assertEqual( urlparser.abspath('file://localhost%s/var/dist/public' % cwd), 'file://localhost%s/var/dist/public' % cwd)
def testSplitHttps(self): urlparser = URLParser() self.assertEqual( urlparser.urlsplit('https://*****:*****@jarn.com/public'), ('https', 'stefan:secret', 'jarn.com', '/public', '', ''))
def testFileUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file://'), True)
def testSplitRelativeFile(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('file:var/dist/public'), ('file', '', '', 'var/dist/public', '', ''))
def testFalsePositives(self): # Everything with a colon matches the regex... urlparser = URLParser() self.assertEqual(urlparser.is_ssh_url('foo:'), True)