trustcafe-api-wrapper/tests/wrappers/react.py
2026-04-02 23:51:29 +01:00

31 lines
No EOL
1.4 KiB
Python

import unittest
from trustcafeapiwrapper.wrappers.reaction.react import react
class TestReact(unittest.TestCase):
def test_react_to_post(self):
reaction_type = 'like'
parent_path = '/'
item_path = '/post/12345'
result = react(reaction_type, parent_path, item_path)
self.assertIsInstance(result, dict)
self.assertIn("job_function", result)
self.assertIn("payload", result)
self.assertEqual(result["job_function"], "reaction.react")
self.assertEqual(result["payload"]["reaction"], reaction_type)
self.assertEqual(result["payload"]["parent"]["pk"], "maintrunk#maintrunk")
self.assertEqual(result["payload"]["parent"]["sk"], "post#12345")
def test_react_to_comment(self):
reaction_type = 'like'
parent_path = '/post/12345'
item_path = '/comment/67890'
result = react(reaction_type, parent_path, item_path)
self.assertIsInstance(result, dict)
self.assertIn("job_function", result)
self.assertIn("payload", result)
self.assertEqual(result["job_function"], "reaction.react")
self.assertEqual(result["payload"]["reaction"], reaction_type)
self.assertEqual(result["payload"]["parent"]["pk"], "post#12345")
self.assertEqual(result["payload"]["parent"]["sk"], "comment#67890")