예제 #1
0
    def test_download_file(self):
        self.mock.StubOutWithMock(PodcastItem, 'download_file')
        PodcastItem.download_file()

        self.mock.ReplayAll()
        tasks.download_file(33)
        self.mock.VerifyAll()
예제 #2
0
    def test_update_items_download_arg_true(self):
        feed_content = '''
        <rss version="2.0">
            <channel>
                <title>Fake Feed</title>
                <item>
                    <guid isPermaLink="false">/ep123.mp3</guid>
                    <enclosure url="http://example.com/ep123.mp3"
                        type="audio/mpeg" />
                </item>
            </channel>
        </rss>
        '''
        tree = etree.fromstring(feed_content).find('channel')
        channel = PodcastChannel.objects.create(url='http://example.com')

        self.mock.StubOutWithMock(PodcastItem, 'download_file')
        PodcastItem.download_file()
        self.mock.StubOutWithMock(model_logger, 'info')
        model_logger.info('Found 1 new items')

        self.mock.ReplayAll()
        channel.update_items(tree, download=True)
        self.mock.VerifyAll()

        item = channel.podcast_items.get()
        self.assertEqual(channel.podcast_items.count(), 1)
        self.assertEqual(item.guid, '/ep123.mp3')
예제 #3
0
    def test_delete_file_wo_file(self):
        self.mock.StubOutWithMock(FieldFile, 'delete')

        item = PodcastItem()

        self.mock.ReplayAll()
        item.delete_file()
        self.mock.VerifyAll()
예제 #4
0
    def test_cleanup_item_delete_signal(self):
        self.mock.StubOutWithMock(PodcastItem, 'delete_file')
        PodcastItem.delete_file()
        item = PodcastItem.objects.create(
            channel=PodcastChannel.objects.create(), guid='/ep123.mp3',
            url='http://example.com/ep123.mp3')

        self.mock.ReplayAll()
        item.delete()
        self.mock.VerifyAll()
예제 #5
0
    def test_delete_file(self):
        self.mock.StubOutWithMock(FieldFile, 'delete')
        FieldFile.delete()

        item = PodcastItem(
            file=SimpleUploadedFile('/ep123.txt', 'file contents'))

        self.mock.ReplayAll()
        item.delete_file()
        self.mock.VerifyAll()
예제 #6
0
    def test_delete(self):
        item = PodcastItem()
        request = RequestFactory().get('')
        self.mock.StubOutWithMock(self.view, 'get_object')
        self.mock.StubOutWithMock(item, 'delete_file')
        self.view.get_object().AndReturn(item)
        item.delete_file()
        
        self.mock.ReplayAll()
        resp = self.view.delete(request)
        self.mock.VerifyAll()

        self.assertEqual(resp.status_code, 204)
예제 #7
0
 def test_media_type_unknown(self):
     item = PodcastItem(file_type='image/jpeg')
     self.assertEqual(item.media_type, 'unknown')
예제 #8
0
 def test_media_type_video(self):
     item = PodcastItem(file_type='video/mpeg')
     self.assertEqual(item.media_type, 'video')
예제 #9
0
 def test_media_type_audio(self):
     item = PodcastItem(file_type='audio/mpeg')
     self.assertEqual(item.media_type, 'audio')
예제 #10
0
    def test_unicode(self):
        channel = PodcastChannel(title='Fake Feed')
        item = PodcastItem(channel=channel, title='Episode 123')

        self.assertEqual(unicode(item), 'Fake Feed - Episode 123')