Logo Search packages:      
Sourcecode: jockey version File versions  Download package

def ui::UITest::test_download_http_nocancel (   self  ) 

download_url(), HTTP, no cancelling

Definition at line 544 of file ui.py.

00544                                          :
        '''download_url(), HTTP, no cancelling'''

        ui = sandbox.TestUI()

        # temporary file
        self._fork_http_server()
        (fname, h) = ui.download_url('http://localhost:8427/stuff')
        self._join_http_server()
        self.assertEqual(open(fname).read(), self.big_file_contents)
        os.unlink(fname)

        self.assertRaises(IndexError, ui.pop_error)

        # we got progress reports
        self.assertEqual(ui.cur_download, ['http://localhost:8427/stuff',
            len(self.big_file_contents), len(self.big_file_contents)])

        # specified file name
        dest = os.path.join(OSLib.inst.workdir, 'destfile')
        self._fork_http_server()
        (fname, h) = ui.download_url('http://localhost:8427/stuff', dest)
        self._join_http_server()
        self.assertEqual(fname, dest)
        self.assertEqual(open(dest).read(), self.big_file_contents)
        os.unlink(dest)

        self.assertRaises(IndexError, ui.pop_error)

        # we got progress reports
        self.assertEqual(ui.cur_download, ['http://localhost:8427/stuff',
            len(self.big_file_contents), len(self.big_file_contents)])

        # nonexisting file
        self._fork_http_server()
        (fname, h) = ui.download_url('http://localhost:8427/nonexisting')
        self._join_http_server()
        self.assertEqual(fname, None)

        # one error message about download failure
        self.assert_(ui.pop_error())
        self.assertRaises(IndexError, ui.pop_error)

        # nonexisting server
        self._fork_http_server()
        (fname, h) = ui.download_url('http://i.do.not.exist/nonexisting')
        self._join_http_server(kill=True)
        self.assertEqual(fname, None)

        # one error message about download failure
        self.assert_(ui.pop_error())
        self.assertRaises(IndexError, ui.pop_error)

    def test_download_http_cancel(self):


Generated by  Doxygen 1.6.0   Back to index