예제 #1
0
 def test_str(self):
     media = InlineMedia(path="path1", caption="caption1")
     no_caption = InlineMedia(path="path1")
     gif = InlineGif(path="gif_path1", caption="gif_caption1")
     image = InlineImage(path="image_path1", caption="image_caption1")
     video = InlineVideo(path="video_path1", caption="video_caption1")
     media.media_id = "media_media_id"
     no_caption.media_id = "media_media_id_no_caption"
     gif.media_id = "gif_media_id"
     image.media_id = "image_media_id"
     video.media_id = "video_media_id"
     assert str(media) == '\n\n![None](media_media_id "caption1")\n\n'
     assert str(no_caption) == '\n\n![None](media_media_id_no_caption "")\n\n'
     assert str(gif) == '\n\n![gif](gif_media_id "gif_caption1")\n\n'
     assert str(image) == '\n\n![img](image_media_id "image_caption1")\n\n'
     assert str(video) == '\n\n![video](video_media_id "video_caption1")\n\n'
예제 #2
0
def postVideo(subreddit, post_text, video):
    cached_url.get(video, mode='b', force_cache=True)
    title, content = splitText(post_text)
    content += '{video}'
    return subreddit.submit(title,
                            selftext=content,
                            inline_media={
                                "video":
                                InlineVideo(path=cached_url.getFilePath(video))
                            })
예제 #3
0
 def test_repr(self):
     media = InlineMedia(path="path1", caption="caption1")
     no_caption = InlineMedia(path="path1")
     gif = InlineGif(path="gif_path1", caption="gif_caption1")
     image = InlineImage(path="image_path1", caption="image_caption1")
     video = InlineVideo(path="video_path1", caption="video_caption1")
     assert repr(media) == "<InlineMedia caption='caption1'>"
     assert repr(no_caption) == "<InlineMedia caption=None>"
     assert repr(gif) == "<InlineGif caption='gif_caption1'>"
     assert repr(image) == "<InlineImage caption='image_caption1'>"
     assert repr(video) == "<InlineVideo caption='video_caption1'>"
예제 #4
0
 def test_submit_inline_media__invalid_path(self):
     message = "'invalid_image_path' is not a valid file path."
     subreddit = Subreddit(self.reddit, display_name="name")
     gif = InlineGif("invalid_image_path", "optional caption")
     image = InlineImage("invalid_image_path", "optional caption")
     video = InlineVideo("invalid_image_path", "optional caption")
     selftext = "Text with {gif1}, {image1}, and {video1} inline"
     media = {"gif1": gif, "image1": image, "video1": video}
     with pytest.raises(ValueError) as excinfo:
         subreddit.submit("title", selftext=selftext, inline_media=media)
     assert str(excinfo.value) == message