def test_remove_unknown_source(self): src1 = testutils.mock_source('foo') src2 = testutils.mock_source('bar') self.wait() with self.assertRaises(DownloadNotFoundError): self.app.cancel(src1) with self.assertRaises(DownloadNotFoundError): self.app.archive(src2)
def test_unexpected_download_from_plugin(self): src1 = testutils.mock_source('foo') src2 = testutils.mock_source('bar') self.app.download(src1) self.wait() fake_list = self.foreign_ids([src1, src2]) with unittest.mock.patch.object(self.plugin_class(), 'list', return_value=fake_list): self.assertEqual(set(self.app.downloads.list()), set([src1]))
def test_handle_unexpected_remove_from_plugin_as_cancel(self): src1 = testutils.mock_source('foo') src2 = testutils.mock_source('bar') self.app.download(src1) self.app.download(src2) self.wait() fake_list = self.foreign_ids([src1]) with unittest.mock.patch.object(self.plugin_class(), 'list', return_value=fake_list): self.app.downloads.sync() self.assertEqual(src2.download, None)
def test_add(self): src1 = testutils.mock_source('foo') self.app.download(src1) self.wait() self.assertTrue(src1.download is not None) self.assertEqual(set(self.app.downloads.list()), set([src1]))
def test_archive(self): src1 = testutils.mock_source('foo') self.app.download(src1) self.app.archive(src1) self.wait() self.assertEqual(src1.download.state, DownloadState.ARCHIVED) self.assertEqual(self.app.downloads.list(), [])
def test_cancel(self): src1 = testutils.mock_source('foo') self.app.download(src1) self.app.cancel(src1) self.wait() self.assertEqual(src1.download, None) self.assertEqual(self.app.get_downloads(), [])
def test_add_duplicated(self): src1 = testutils.mock_source('foo') self.app.download(src1) self.wait() with self.assertRaises(DuplicatedDownloadError): self.app.download(src1) self.assertEqual(set(self.app.downloads.list()), set([src1]))
def test_handle_unexpected_remove_from_plugin_as_archive(self): src1 = testutils.mock_source('foo') src2 = testutils.mock_source('bar') self.app.download(src1) self.app.download(src2) self.wait() # Manually update state of src2 src2.download.state = DownloadState.SHARING # Mock plugin list to not list src2 fake_list = self.foreign_ids([src1]) with unittest.mock.patch.object(self.plugin_class(), 'list', return_value=fake_list): self.app.get_downloads() self.assertEqual(src2.download.state, DownloadState.ARCHIVED)
def parse(self, name, **kwargs): source = mock_source(name, **kwargs) entity, tags = self.mp.parse(source) return source, entity, tags
def s(*args, **kwargs): return analyze(mock_source(*args, **kwargs))
def test_info(self): src = testutils.mock_source('foo') self.app.download(src) self.app.downloads.get_info(src)