Update existing tests & add reddit image post
This commit is contained in:
parent
c502caa8cf
commit
f1ba1f99fe
2 changed files with 40 additions and 10 deletions
|
|
@ -741,7 +741,7 @@ unsanitized_mock = {
|
|||
"author_flair_richtext": [],
|
||||
"gildings": {},
|
||||
"content_categories": None,
|
||||
"is_self": False,
|
||||
"is_self": True,
|
||||
"mod_note": None,
|
||||
"crosspost_parent_list": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class RedditBuilderTestCase(TestCase):
|
|||
def test_update_posts(self):
|
||||
subreddit = SubredditFactory()
|
||||
existing_post = RedditPostFactory(
|
||||
remote_identifier="hngsj8",
|
||||
remote_identifier="hm0qct",
|
||||
author="Old author",
|
||||
title="Old title",
|
||||
body="Old body",
|
||||
|
|
@ -109,17 +109,24 @@ class RedditBuilderTestCase(TestCase):
|
|||
|
||||
existing_post.refresh_from_db()
|
||||
|
||||
self.assertEquals(existing_post.remote_identifier, "hngsj8")
|
||||
self.assertEquals(existing_post.author, "nixcraft")
|
||||
self.assertEquals(existing_post.title, "KeePassXC 2.6.0 released")
|
||||
self.assertEquals(existing_post.body, "")
|
||||
self.assertEquals(existing_post.remote_identifier, "hm0qct")
|
||||
self.assertEquals(existing_post.author, "AutoModerator")
|
||||
self.assertEquals(
|
||||
existing_post.title,
|
||||
"Linux Experiences/Rants or Education/Certifications thread - July 06, 2020",
|
||||
)
|
||||
self.assertIn(
|
||||
"This megathread is also to hear opinions from anyone just starting out "
|
||||
"with Linux or those that have used Linux (GNU or otherwise) for a long time.",
|
||||
existing_post.body,
|
||||
)
|
||||
self.assertEquals(
|
||||
existing_post.publication_date,
|
||||
pytz.utc.localize(datetime(2020, 7, 8, 15, 11, 6)),
|
||||
pytz.utc.localize(datetime(2020, 7, 6, 6, 11, 22)),
|
||||
)
|
||||
self.assertEquals(
|
||||
existing_post.url,
|
||||
"https://www.reddit.com/r/linux/comments/hngsj8/" "keepassxc_260_released/",
|
||||
"https://www.reddit.com/r/linux/comments/hm0qct/linux_experiencesrants_or_educationcertifications/",
|
||||
)
|
||||
|
||||
def test_html_sanitizing(self):
|
||||
|
|
@ -221,9 +228,32 @@ class RedditBuilderTestCase(TestCase):
|
|||
"Linux Experiences/Rants or Education/Certifications thread - July 06, 2020",
|
||||
)
|
||||
|
||||
@skip("Not implemented")
|
||||
def test_image_post(self):
|
||||
pass
|
||||
builder = RedditBuilder
|
||||
|
||||
subreddit = SubredditFactory()
|
||||
mock_stream = MagicMock(rule=subreddit)
|
||||
|
||||
with builder((image_mock, mock_stream)) as builder:
|
||||
builder.save()
|
||||
|
||||
posts = {post.remote_identifier: post for post in Post.objects.all()}
|
||||
|
||||
self.assertCountEqual(("hr64xh", "hr4bxo", "hr14y5", "hr2fv0"), posts.keys())
|
||||
|
||||
post = posts["hr64xh"]
|
||||
|
||||
title = (
|
||||
"Ya’ll, I just can’t... this is my "
|
||||
"son, Judah. My wife and I have no "
|
||||
"idea how we created such a "
|
||||
"beautiful child."
|
||||
)
|
||||
url = "https://i.redd.it/cm2qybia1va51.jpg"
|
||||
|
||||
self.assertEquals(
|
||||
f'<div><img alt="{title}" src="{url}" loading="lazy" /></div>', post.body
|
||||
)
|
||||
|
||||
@skip("Not implemented")
|
||||
def test_external_image_post(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue