Ejemplo n.º 1
0
 def test_podcast_duplicates(self):
     # make sure duplicate name, or archive type and broadcast id not allowed
     with utils.temp_podcast(self.client) as podcast1:
         with utils.temp_dir() as temp_dir:
             with self.assertRaises(HathorException) as error:
                 self.client.podcast_create(podcast1['archive_type'],
                                            podcast1['broadcast_id'] + '1',
                                            podcast1['name'],
                                            file_location=temp_dir)
             self.check_error_message('Cannot create podcast, name was %s' % podcast1['name'], error)
             with self.assertRaises(HathorException) as error:
                 self.client.podcast_create(podcast1['archive_type'],
                                            podcast1['broadcast_id'],
                                            podcast1['name'] + 's',
                                            file_location=temp_dir)
             self.check_error_message('Cannot create podcast, name was %ss' % podcast1['name'], error)
         # also check updating fails an existing one to one that exists fails
         with utils.temp_podcast(self.client) as podcast2:
             with self.assertRaises(HathorException) as error:
                 self.client.podcast_update(podcast1['id'], podcast_name=podcast2['name'])
             self.check_error_message('Cannot update podcast id:%s' % podcast1['id'], error)
             # also check updating fails an existing one to one that exists fails
             with utils.temp_podcast(self.client) as podcast2:
                 with self.assertRaises(HathorException) as error:
                     self.client.podcast_update(podcast1['id'], podcast_name=podcast2['name'])
                 self.check_error_message('Cannot update podcast id:%s' % podcast1['id'], error)
                 with self.assertRaises(HathorException) as error:
                     self.client.podcast_update(podcast1['id'], broadcast_id=podcast2['broadcast_id'])
                 self.check_error_message('Cannot update podcast id:%s' % podcast1['id'], error)
Ejemplo n.º 2
0
    def test_podcast_location_update(self):
        # check fails with invalid data
        with self.assertRaises(HathorException) as error:
            self.client.podcast_update_file_location(1, 'foo')
        self.check_error_message('Podcast not found for ID:1', error)

        # check works with valid data
        with utils.temp_podcast(self.client, archive_type='rss', broadcast_url=True, max_allowed=2) as podcast:
            httpretty.register_uri(httpretty.GET, podcast['broadcast_id'],
                                   body=history_on_fire.DATA)
            self.client.episode_sync()
            episode_list = self.client.episode_list(only_files=False)
            with utils.temp_audio_file() as mp3_body:
                utils.mock_mp3_download(episode_list[0]['download_url'], mp3_body)
                self.client.episode_download(episode_list[0]['id'])
                old_episode = self.client.episode_show(episode_list[0]['id'])[0]
                with utils.temp_dir(delete=False) as temp:
                    self.client.podcast_update_file_location(podcast['id'], temp)
                    # make sure episode path changed
                    new_episode = self.client.episode_show(episode_list[0]['id'])[0]
                    self.assertTrue(new_episode['file_path'].startswith(temp))
                    self.assertNotEqual(old_episode['file_path'], new_episode['file_path'])
                    # make sure podcast path changed
                    new_podcast = self.client.podcast_show(podcast['id'])[0]
                    self.assertNotEqual(podcast['file_location'], new_podcast['file_location'])
Ejemplo n.º 3
0
 def test_podcast_dir_given(self):
     with test_utils.temp_dir(delete=False) as dir_temp:
         with test_utils.temp_client(podcast_directory=dir_temp) as client_args:
             client = client_args.pop("podcast_client")
             pod_id = client.podcast_create("rss", "1234", utils.random_string())
             podcast = client.podcast_show(pod_id)
             self.assertTrue(podcast[0]["file_location"].startswith(dir_temp))
             os.rmdir(podcast[0]["file_location"])
             client.podcast_delete(pod_id)
Ejemplo n.º 4
0
 def test_podcast_create_with_file_location(self):
     with utils.temp_dir(delete=False) as temp_dir:
         pod_id = self.client.podcast_create('rss', '123', 'foo', file_location=temp_dir)
         pod = self.client.podcast_show(pod_id)[0]
         self.assertEqual(pod['file_location'], temp_dir)
         self.client.podcast_delete(pod_id)
Ejemplo n.º 5
0
 def test_delete_dir(self):
     with test_utils.temp_client(logging_level=logging.WARNING) as client_args:
         client = client_args.pop("podcast_client")
         with test_utils.temp_dir() as temp_dir:
             client._remove_directory(temp_dir)  # pylint:disable=protected-access
             self.assertFalse(os.path.isdir(temp_dir))