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)
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)
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))
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')