Beispiel #1
0
    def test_pass_downloader_args(self):
        w_movie = WikiMovie(title='Test',
                            downloader_args={
                                'img_dir': 'test_path',
                                'supplemented_keywords': ['1', '2', '3']
                            })
        downloader = w_movie.image_downloader

        self.assertEqual(downloader.img_dir, 'test_path')
        self.assertEqual(downloader.main_keyword, 'Test')
        self.assertListEqual(downloader.supplemented_keywords, ['1', '2', '3'])

        downloader.driver.quit()
Beispiel #2
0
    def test_create_default_downloader(self):
        w_movie = WikiMovie(title='Test')
        downloader = w_movie.image_downloader

        actual_keywords = [
            ' ', 'Arts and entertainment', 'Computing', 'People',
            'Science and technology', 'Sports', 'Other uses'
        ]

        self.assertEqual(downloader.main_keyword, 'Test',
                         'Incorrect main keyword')
        self.assertEqual(downloader.url_dir,
                         repository_root / 'data' / 'url_files' / 'Test',
                         'Incorrect url directory')
        self.assertListEqual(downloader.supplemented_keywords, actual_keywords,
                             'Incorrect keyword list')

        downloader.driver.quit()
Beispiel #3
0
    def test_linux_format(self):
        w_movie = WikiMovie('Condyle', 'sys_tts')

        # Mocked methods to increase speed of test. Only care about correct call to default linux narration engine
        w_movie.prepare_images = mock.MagicMock(name='prepare_images')
        w_movie.slideshow = mock.MagicMock(name='slideshow')

        with mock.patch('wiki_movie.narrators.engines.sys_tts.save_linux'
                        ) as mock_save_linux:
            w_movie.make_movie()

            expected_file_name = str(DATA_DIR / 'audio' / 'Condyle' /
                                     'Condyle_header')

            mock_save_linux.assert_called()
            mock_save_linux.assert_any_call(message='Condyle',
                                            voice='',
                                            rate='',
                                            file_name=expected_file_name)
Beispiel #4
0
class WikiMovieTest(TestCase):
    def setUp(self):
        self.w_movie = WikiMovie('Condyle')

    def test_skip_overwrite_images(self):
        img_dl = self.w_movie.image_downloader
        with mock.patch.object(img_dl, 'find_and_download') as fd:
            self.w_movie.make_movie(overwrite=False)
            fd.assert_not_called()

    def test_skip_overwrite_speech(self):
        narrator = self.w_movie.narrator
        with mock.patch.object(narrator, 'make_narration') as mn:
            self.w_movie.make_movie(overwrite=False)
            mn.assert_not_called()

    def test_skip_overwrite_video(self):
        with mock.patch(
                'wiki_movie.video.slideshow_functions.save_video') as sv:
            self.w_movie.make_movie(overwrite=False)
            sv.assert_not_called()

    @mock.patch('sys.platform', 'linux')
    def test_linux_format(self):
        w_movie = WikiMovie('Condyle', 'sys_tts')

        # Mocked methods to increase speed of test. Only care about correct call to default linux narration engine
        w_movie.prepare_images = mock.MagicMock(name='prepare_images')
        w_movie.slideshow = mock.MagicMock(name='slideshow')

        with mock.patch('wiki_movie.narrators.engines.sys_tts.save_linux'
                        ) as mock_save_linux:
            w_movie.make_movie()

            expected_file_name = str(DATA_DIR / 'audio' / 'Condyle' /
                                     'Condyle_header')

            mock_save_linux.assert_called()
            mock_save_linux.assert_any_call(message='Condyle',
                                            voice='',
                                            rate='',
                                            file_name=expected_file_name)
Beispiel #5
0
 def setUp(self):
     self.w_movie = WikiMovie('Condyle')
Beispiel #6
0
 def test_create_darwin_platform_default_narrator(self):
     w_movie = WikiMovie(title='Test')
     narrator_cls_name = w_movie.narrator.__class__.__name__
     self.assertEqual('SystemNarrator', narrator_cls_name)
Beispiel #7
0
 def test_create_with_narrator_name(self):
     w_movie = WikiMovie(title='Test', narrator_name='dc_tts')
     narrator_cls_name = w_movie.narrator.__class__.__name__
     self.assertEqual('DcttsNarrator', narrator_cls_name)