def test_parse_ftp_url_login_success(self):
        url = 'ftp://*****:*****@speedtest.tele2.net:21/path/to/file/512KB.zip'

        urlInfo = GenericDownloader.parseUrl(url)
        urlInfo.outputFilenameSuffix = ''

        expectedUrlInfo = UrlInfo(url)
        expectedUrlInfo.isValid = True
        expectedUrlInfo.message = ''
        expectedUrlInfo.port = 21
        expectedUrlInfo.outputFilename = '512KB'
        expectedUrlInfo.outputFilenameExtension = 'zip'
        expectedUrlInfo.outputFilenameSuffix = ''
        expectedUrlInfo.scheme = 'ftp'
        expectedUrlInfo.netloc = 'demo-user:[email protected]:21'
        expectedUrlInfo.hostname = 'speedtest.tele2.net'
        expectedUrlInfo.path = '/path/to/file/512KB.zip'
        expectedUrlInfo.params = ''
        expectedUrlInfo.query = ''
        expectedUrlInfo.fragment = ''
        expectedUrlInfo.username = '******'
        expectedUrlInfo.password = '******'
        expectedUrlInfo.dirName = '/path/to/file'

        self.assertEqual(urlInfo, expectedUrlInfo)
    def test_parse_http_url_success(self):
        url = 'https://i.imgur.com/slmM8rc.jpg'
        urlInfo = GenericDownloader.parseUrl(url)
        urlInfo.outputFilenameSuffix = ''

        expectedUrlInfo = UrlInfo(url)
        expectedUrlInfo.inputUrl = 'https://i.imgur.com/slmM8rc.jpg'
        expectedUrlInfo.isValid = True
        expectedUrlInfo.message = ''
        expectedUrlInfo.port = 0
        expectedUrlInfo.outputFilename = 'slmM8rc'
        expectedUrlInfo.outputFilenameExtension = 'jpg'
        expectedUrlInfo.outputFilenameSuffix = ''
        expectedUrlInfo.scheme = 'https'
        expectedUrlInfo.netloc = 'i.imgur.com'
        expectedUrlInfo.hostname = 'i.imgur.com'
        expectedUrlInfo.path = '/slmM8rc.jpg'
        expectedUrlInfo.params = ''
        expectedUrlInfo.query = ''
        expectedUrlInfo.fragment = ''
        expectedUrlInfo.username = None
        expectedUrlInfo.password = None
        expectedUrlInfo.dirName = ''

        self.assertEqual(urlInfo, expectedUrlInfo)
    def test_parse_ftp_url_anon_success(self):
        url = 'ftp://speedtest.tele2.net/512KB.zip'
        urlInfo = GenericDownloader.parseUrl(url)
        urlInfo.outputFilenameSuffix = ''

        expectedUrlInfo = UrlInfo(url)
        expectedUrlInfo.isValid = True
        expectedUrlInfo.message = ''
        expectedUrlInfo.port = 0
        expectedUrlInfo.outputFilename = '512KB'
        expectedUrlInfo.outputFilenameExtension = 'zip'
        expectedUrlInfo.outputFilenameSuffix = ''
        expectedUrlInfo.scheme = 'ftp'
        expectedUrlInfo.netloc = 'speedtest.tele2.net'
        expectedUrlInfo.hostname = 'speedtest.tele2.net'
        expectedUrlInfo.path = '/512KB.zip'
        expectedUrlInfo.params = ''
        expectedUrlInfo.query = ''
        expectedUrlInfo.fragment = ''
        expectedUrlInfo.username = None
        expectedUrlInfo.password = None
        expectedUrlInfo.dirName = ''

        self.assertEqual(urlInfo, expectedUrlInfo)
 def test_parse_http_url_invalid(self):
     url = 'INVALID_URL'
     urlInfo = GenericDownloader.parseUrl(url)
     self.assertEqual(urlInfo.isValid, False)