Post update
This commit is contained in:
parent
1995e0479f
commit
a42a3b65d9
9 changed files with 116 additions and 17 deletions
|
|
@ -13,10 +13,10 @@ class TestGetChildSpkskFromPaths(unittest.TestCase):
|
|||
self.assertEqual(get_child_spksk_from_paths(parent_path, item_path), expected_output)
|
||||
|
||||
def test_comment_reaction(self):
|
||||
parent_path = '/post/12345'
|
||||
parent_path = '/post/12345-abcv'
|
||||
item_path = '/comment/67890'
|
||||
expected_output = {
|
||||
"pk": "post#12345",
|
||||
"pk": "post#12345-abcv",
|
||||
"sk": "comment#67890",
|
||||
"entity": "comment",
|
||||
"slug": "67890"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class TestReact(unittest.TestCase):
|
|||
def test_react_to_post(self):
|
||||
reaction_type = 'like'
|
||||
parent_path = '/'
|
||||
item_path = '/post/12345'
|
||||
item_path = '/post/12345-abcv'
|
||||
result = react(reaction_type, parent_path, item_path)
|
||||
|
||||
self.assertIsInstance(result, dict)
|
||||
|
|
@ -14,13 +14,13 @@ class TestReact(unittest.TestCase):
|
|||
self.assertEqual(result["job_function"], "reaction.reacttosomething")
|
||||
self.assertEqual(result["payload"]["reaction"], reaction_type)
|
||||
self.assertEqual(result["payload"]["parent"]["pk"], "maintrunk#maintrunk")
|
||||
self.assertEqual(result["payload"]["parent"]["sk"], "post#12345")
|
||||
self.assertEqual(result["payload"]["parent"]["sk"], "post#12345-abcv")
|
||||
self.assertEqual(result["payload"]["parent"]["entity"], "post")
|
||||
self.assertEqual(result["payload"]["parent"]["slug"], "12345")
|
||||
self.assertEqual(result["payload"]["parent"]["slug"], "12345-abcv")
|
||||
|
||||
def test_react_to_comment(self):
|
||||
reaction_type = 'like'
|
||||
parent_path = '/post/12345'
|
||||
parent_path = '/post/12345-abcv'
|
||||
item_path = '/comment/67890'
|
||||
result = react(reaction_type, parent_path, item_path)
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class TestReact(unittest.TestCase):
|
|||
self.assertIn("payload", result)
|
||||
self.assertEqual(result["job_function"], "reaction.reacttosomething")
|
||||
self.assertEqual(result["payload"]["reaction"], reaction_type)
|
||||
self.assertEqual(result["payload"]["parent"]["pk"], "post#12345")
|
||||
self.assertEqual(result["payload"]["parent"]["pk"], "post#12345-abcv")
|
||||
self.assertEqual(result["payload"]["parent"]["sk"], "comment#67890")
|
||||
self.assertEqual(result["payload"]["parent"]["entity"], "comment")
|
||||
self.assertEqual(result["payload"]["parent"]["slug"], "67890")
|
||||
30
tests/wrappers/update_post.py
Normal file
30
tests/wrappers/update_post.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import unittest
|
||||
from trustcafeapiwrapper.wrappers.post.update_post import update_post
|
||||
class TestUpdatePost(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.post_text = "This is an updated test post created via the update_post wrapper function."
|
||||
self.blur_label = None
|
||||
self.card_url = None
|
||||
self.collaborative = False
|
||||
|
||||
def test_update_post(self):
|
||||
result = update_post(
|
||||
parent_path='/',
|
||||
post_path='/post/1235-abcv',
|
||||
post_text=self.post_text,
|
||||
blur_label=self.blur_label,
|
||||
card_url=self.card_url,
|
||||
collaborative=self.collaborative
|
||||
)
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertIn("job_function", result)
|
||||
self.assertIn("payload", result)
|
||||
self.assertEqual(result["job_function"], "post.update")
|
||||
self.assertEqual(result["payload"]["postText"], self.post_text)
|
||||
self.assertEqual(result["payload"]["blurLabel"], self.blur_label)
|
||||
self.assertEqual(result["payload"]["cardUrl"], self.card_url)
|
||||
self.assertEqual(result["payload"]["collaborative"], self.collaborative)
|
||||
self.assertEqual(result["payload"]["postSlug"], "1235-abcv")
|
||||
self.assertEqual(result["payload"]["key"]["pk"], "maintrunk#maintrunk")
|
||||
self.assertEqual(result["payload"]["key"]["sk"], "post#1235-abcv")
|
||||
self.assertNotIn("slug", result["payload"]["key"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue