Add external image post test

This commit is contained in:
sonny 2020-07-20 23:58:46 +02:00
parent f1ba1f99fe
commit c100ff03cf
2 changed files with 369 additions and 973 deletions

File diff suppressed because it is too large Load diff

View file

@ -251,13 +251,53 @@ class RedditBuilderTestCase(TestCase):
) )
url = "https://i.redd.it/cm2qybia1va51.jpg" url = "https://i.redd.it/cm2qybia1va51.jpg"
self.assertEquals(
"https://www.reddit.com/r/aww/comments/hr64xh/yall_i_just_cant_this_is_my_son_judah_my_wife_and/",
post.url,
)
self.assertEquals( self.assertEquals(
f'<div><img alt="{title}" src="{url}" loading="lazy" /></div>', post.body f'<div><img alt="{title}" src="{url}" loading="lazy" /></div>', post.body
) )
@skip("Not implemented")
def test_external_image_post(self): def test_external_image_post(self):
pass builder = RedditBuilder
subreddit = SubredditFactory()
mock_stream = MagicMock(rule=subreddit)
with builder((external_image_mock, mock_stream)) as builder:
builder.save()
posts = {post.remote_identifier: post for post in Post.objects.all()}
self.assertCountEqual(("hr41am", "huoldn"), posts.keys())
post = posts["hr41am"]
url = "http://gfycat.com/thatalivedogwoodclubgall"
title = "Excited cows have a new brush!"
self.assertEquals(
f'<div><a target="_blank" rel="noopener noreferrer" alt="{title}" href="{url}" class="link">Direct url</a></div>',
post.body,
)
self.assertEquals(
"https://www.reddit.com/r/aww/comments/hr41am/excited_cows_have_a_new_brush/",
post.url,
)
post = posts["huoldn"]
url = "https://i.imgur.com/usfMVUJ.jpg"
title = "Novosibirsk Zoo welcomes 16 cobalt-eyed Pallass cat kittens"
self.assertEquals(
f'<div><img alt="{title}" src="{url}" loading="lazy" /></div>', post.body
)
self.assertEquals(
"https://www.reddit.com/r/aww/comments/huoldn/novosibirsk_zoo_welcomes_16_cobalteyed_pallass/",
post.url,
)
@skip("Not implemented") @skip("Not implemented")
def test_video_post(self): def test_video_post(self):
@ -267,6 +307,10 @@ class RedditBuilderTestCase(TestCase):
def test_external_video_post(self): def test_external_video_post(self):
pass pass
@skip("Not implemented")
def test_external_gifv_video_post(self):
pass
@skip("Not implemented") @skip("Not implemented")
def test_link_only_post(self): def test_link_only_post(self):
pass pass