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 testFileUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file://'), True)
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 testWhitespace(self): urlparser = URLParser() self.assertEqual(urlparser.is_url(' http://'), False)
def testLocalhostWithTilde(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file://localhost/~stefan/public'), True)
def testGitUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('git://'), True)
def testSvn(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('svn://jarn.com/public'), 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 testSplitLocalhostWithTilde(self): urlparser = URLParser() self.assertEqual(urlparser.split('file://localhost/~stefan/public'), ('file', '', 'localhost', '/~stefan/public', '', ''))
def testSplitUnsupported(self): urlparser = URLParser() self.assertEqual(urlparser.split('ftp://jarn.com/public'), ('ftp', '', 'jarn.com', '/public', '', ''))
def testBadUrl(self): urlparser = URLParser() self.assertEqual( urlparser.to_ssh_url('https://[email protected]/var/dist/public'), 'https://[email protected]/var/dist/public')
def testRsync(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('rsync://jarn.com/public'), True)
def testHttpsUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('https://'), True)
def testRelativeFile(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file:var/dist/public'), True)
def testWhitespace(self): urlparser = URLParser() self.assertEqual( urlparser.to_ssh_url(' ssh://[email protected]/var/dist/public'), ' ssh://[email protected]/var/dist/public')
def testUnsupported(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('ftp://jarn.com/public'), True)
def testEmptyString(self): urlparser = URLParser() self.assertEqual(urlparser.to_ssh_url(''), '')
def testRelativeFile(self): urlparser = URLParser() cwd = os.getcwd() self.assertEqual(urlparser.abspath('file:var/dist/public'), 'file://%s/var/dist/public' % cwd)
def testSshUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('ssh://'), True)
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 testBadScheme(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('ftp//'), False)
def testSplitRelativeFileWithTilde(self): urlparser = URLParser() self.assertEqual(urlparser.split('file:~stefan/public'), ('file', '', '', '~stefan/public', '', ''))
def testNonFile(self): urlparser = URLParser() self.assertEqual(urlparser.abspath('svn://jarn.com/public'), 'svn://jarn.com/public')
def testSplitGitWithTilde(self): urlparser = URLParser() self.assertEqual(urlparser.split('git://jarn.com/~stefan/public'), ('git', '', 'jarn.com', '/~stefan/public', '', ''))
def testRelativeFileUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file:'), True)
def testSplitBadUrl(self): urlparser = URLParser() self.assertEqual(urlparser.split('ssh:[email protected]/public'), ('', '', '', 'ssh:[email protected]/public', '', ''))
def testGit(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('git://jarn.com/public'), True)
def testEmptyString(self): urlparser = URLParser() self.assertEqual(urlparser.is_url(''), False)
def testSsh(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('ssh://[email protected]//hg/public'), True)
def testSplitSvn(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('svn://jarn.com/public'), ('svn', '', 'jarn.com', '/public', '', ''))
def testHttps(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('https://jarn.com/public'), True)
def testSplitGit(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('git://jarn.com/public'), ('git', '', 'jarn.com', '/public', '', ''))
def testRelativeFileWithTilde(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('file:~stefan/public'), True)
def testSplitRsync(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('rsync://jarn.com/public'), ('rsync', '', 'jarn.com', '/public', '', ''))
def testGitWithTilde(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('git://jarn.com/~stefan/public'), True)
def testSvnUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('svn://'), True)
def testBadUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('ssh:'), False)
def testSplitSsh(self): urlparser = URLParser() self.assertEqual( urlparser.urlsplit('ssh://[email protected]//hg/public'), ('ssh', 'stefan', 'jarn.com', '//hg/public', '', ''))
def testRsyncUrl(self): urlparser = URLParser() self.assertEqual(urlparser.is_url('rsync://'), True)
def testSplitHttp(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('http://jarn.com/public'), ('http', '', 'jarn.com', '/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 testSplitFile(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('file:///var/dist/public'), ('file', '', '', '/var/dist/public', '', ''))
def testSplitRelativeFile(self): urlparser = URLParser() self.assertEqual(urlparser.urlsplit('file:var/dist/public'), ('file', '', '', 'var/dist/public', '', ''))
def testSplitRelativeFile(self): urlparser = URLParser() self.assertEqual(urlparser.split('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)