コード例 #1
0
    def create_download(self, name, link_list, passwd=""):
        links = self.parse_link_list(link_list)

        dw = Download(name, links, passwd)
        dw.set_save_function(self.save_data)

        self.append_download(dw)
コード例 #2
0
ファイル: link_loader.py プロジェクト: kpj/PLoader
	def create_download(self, name, link_list, passwd=""):
		links = self.parse_link_list(link_list)

		dw = Download(name, links, passwd)
		dw.set_save_function(self.save_data)

		self.append_download(dw)
コード例 #3
0
    def test_append_download(self):
        # TODO: little hack to reduce amount of work
        self.link_loader.append_download(Download('42', []))
        self.assertEqual(len(self.link_loader.data), 1)

        self.link_loader.append_download([Download('42', [])])
        self.assertEqual(len(self.link_loader.data), 2)

        self.link_loader.append_download(
            [Download('23', []), Download('42', [])])
        self.assertEqual(len(self.link_loader.data), 4)
コード例 #4
0
    def test_get_unstarted_download(self):
        sample_dw = Download('bla', [{
            "link": "http://foo.bar.baz/other_stuff.avi",
            "filename": "",
            "status": "not started"
        }, {
            "link": "http://foo.bar.baz/other_stuff2.avi",
            "filename": "",
            "status": "not started"
        }], 'blub')

        # TODO: find better way to compare objects
        self.assertEqual(repr(self.link_loader.get_unstarted_download()),
                         repr(sample_dw))
コード例 #5
0
    def test_get_status(self):
        # incomplete list arguments

        links = [{'status': 'not started'}, {'status': 'not started'}]
        dw = Download('foo', links, 'bar')
        self.assertEqual(dw.get_status(), 'not started')

        links = [{'status': 'loading'}, {'status': 'not started'}]
        dw = Download('foo', links, 'bar')
        self.assertEqual(dw.get_status(), 'loading')

        links = [{'status': 'success'}, {'status': 'not started'}]
        dw = Download('foo', links, 'bar')
        self.assertEqual(dw.get_status(), 'loading')

        links = [{'status': 'loading'}, {'status': 'loading'}]
        dw = Download('foo', links, 'bar')
        self.assertEqual(dw.get_status(), 'loading')

        links = [{'status': 'success'}, {'status': 'loading'}]
        dw = Download('foo', links, 'bar')
        self.assertEqual(dw.get_status(), 'loading')

        links = [{'status': 'success'}, {'status': 'success'}]
        dw = Download('foo', links, 'bar')
        self.assertEqual(dw.get_status(), 'success')
コード例 #6
0
ファイル: test_download_handler.py プロジェクト: kpj/PLoader
	def test_get_status(self):
		# incomplete list arguments

		links = [{'status': 'not started'}, {'status': 'not started'}]
		dw = Download('foo', links, 'bar')
		self.assertEqual(dw.get_status(), 'not started')

		links = [{'status': 'loading'}, {'status': 'not started'}]
		dw = Download('foo', links, 'bar')
		self.assertEqual(dw.get_status(), 'loading')

		links = [{'status': 'success'}, {'status': 'not started'}]
		dw = Download('foo', links, 'bar')
		self.assertEqual(dw.get_status(), 'loading')

		links = [{'status': 'loading'}, {'status': 'loading'}]
		dw = Download('foo', links, 'bar')
		self.assertEqual(dw.get_status(), 'loading')

		links = [{'status': 'success'}, {'status': 'loading'}]
		dw = Download('foo', links, 'bar')
		self.assertEqual(dw.get_status(), 'loading')

		links = [{'status': 'success'}, {'status': 'success'}]
		dw = Download('foo', links, 'bar')
		self.assertEqual(dw.get_status(), 'success')