コード例 #1
0
    def test_single_mp3_without_mime_enclosure(self):
        single_mp3_without_mime_enclosure = TestStoryAndEnclosure(
            story=create_test_story(
                db=self._DB,
                label='single MP3 enclosure without MIME type set',
                feed=self._TEST_FEED,
            ))

        single_mp3_without_mime_enclosure.enclosures.append(
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id':
                                single_mp3_without_mime_enclosure.stories_id,
                                'url': 'http://www.example.com/test.mp3',
                                'mime_type': '',
                                'length': 100000,
                            }))

        assert viable_story_enclosure(
            db=self._DB,
            stories_id=single_mp3_without_mime_enclosure.stories_id,
        ) == StoryEnclosure.from_db_row(
            single_mp3_without_mime_enclosure.enclosures[0]
        ), ("Story with a single MP3 enclosure without MIME type set should return that enclosure."
            )
コード例 #2
0
    def test_only_video_enclosures(self):
        only_video_enclosures = TestStoryAndEnclosure(story=create_test_story(
            db=self._DB,
            label='only video enclosures',
            feed=self._TEST_FEED,
        ))

        only_video_enclosures.enclosures.extend([
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id': only_video_enclosures.stories_id,
                                'url': 'http://www.example.com/test.mkv',
                                'mime_type': 'video/x-matroska',
                                'length': 100000,
                            }),
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id': only_video_enclosures.stories_id,
                                'url': 'http://www.example.com/test.mp4',
                                'mime_type': 'video/mp4',
                                'length': 100000,
                            }),
        ])

        assert viable_story_enclosure(
            db=self._DB,
            stories_id=only_video_enclosures.stories_id,
        ) == StoryEnclosure.from_db_row(only_video_enclosures.enclosures[0]), (
            "Story with only video enclosures should return the first video enclosure."
        )
コード例 #3
0
    def test_audio_and_video_enclosures(self):
        audio_and_video_enclosures = TestStoryAndEnclosure(
            story=create_test_story(
                db=self._DB,
                label='audio and video enclosures',
                feed=self._TEST_FEED,
            ))

        audio_and_video_enclosures.enclosures.extend([
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id':
                                audio_and_video_enclosures.stories_id,
                                'url': 'http://www.example.com/test.mkv',
                                'mime_type': 'video/x-matroska',
                                'length': 100000,
                            }),
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id':
                                audio_and_video_enclosures.stories_id,
                                'url': 'http://www.example.com/test.aac',
                                'mime_type': 'audio/aac',
                                'length': 100000,
                            }),
        ])

        assert viable_story_enclosure(
            db=self._DB,
            stories_id=audio_and_video_enclosures.stories_id,
        ) == StoryEnclosure.from_db_row(
            audio_and_video_enclosures.enclosures[1]
        ), ("Story with audio and video enclosures should return an audio enclosure."
            )
コード例 #4
0
    def test_multiple_audio_enclosures(self):
        multiple_audio_enclosures = TestStoryAndEnclosure(
            story=create_test_story(
                db=self._DB,
                label='multiple audio enclosures',
                feed=self._TEST_FEED,
            ))

        multiple_audio_enclosures.enclosures.extend([
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id':
                                multiple_audio_enclosures.stories_id,
                                'url': 'http://www.example.com/test.aac',
                                'mime_type': 'audio/aac',
                                'length': 100000,
                            }),
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id':
                                multiple_audio_enclosures.stories_id,
                                'url': 'http://www.example.com/test.mp3',
                                'mime_type': 'audio/mpeg',
                                'length': 100000,
                            }),
        ])

        assert viable_story_enclosure(
            db=self._DB,
            stories_id=multiple_audio_enclosures.stories_id,
        ) == StoryEnclosure.from_db_row(
            multiple_audio_enclosures.enclosures[1]
        ), ("Story with multiple audio enclosures should return a supported audio enclosure."
            )
コード例 #5
0
    def test_no_enclosures(self):
        no_enclosures = TestStoryAndEnclosure(story=create_test_story(
            db=self._DB,
            label='no enclosures',
            feed=self._TEST_FEED,
        ))

        assert viable_story_enclosure(
            db=self._DB,
            stories_id=no_enclosures.stories_id,
        ) is None, "Story with no enclosures."
コード例 #6
0
    def test_enclosure_with_empty_url(self):
        enclosure_with_empty_url = TestStoryAndEnclosure(
            story=create_test_story(
                db=self._DB,
                label='enclosure with empty URL',
                feed=self._TEST_FEED,
            ))

        enclosure_with_empty_url.enclosures.append(
            self._DB.insert(table='story_enclosures',
                            insert_hash={
                                'stories_id':
                                enclosure_with_empty_url.stories_id,
                                'url': '',
                                'mime_type': 'audio/mpeg',
                                'length': 100000,
                            }))

        assert viable_story_enclosure(
            db=self._DB,
            stories_id=enclosure_with_empty_url.stories_id,
        ) is None, "Story with an empty enclosure URL."