Example #1
0
    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)
Example #2
0
    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]))
Example #3
0
    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)
Example #4
0
    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]))
Example #5
0
    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(), [])
Example #6
0
    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(), [])
Example #7
0
    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]))
Example #8
0
    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)
Example #9
0
 def parse(self, name, **kwargs):
     source = mock_source(name, **kwargs)
     entity, tags = self.mp.parse(source)
     return source, entity, tags
Example #10
0
def s(*args, **kwargs):
    return analyze(mock_source(*args, **kwargs))
Example #11
0
 def test_info(self):
     src = testutils.mock_source('foo')
     self.app.download(src)
     self.app.downloads.get_info(src)