Vote casting
This commit is contained in:
parent
8704ad0e70
commit
80786c4965
12 changed files with 152 additions and 42 deletions
24
tests/utils/get_child_spksk_from_paths.py
Normal file
24
tests/utils/get_child_spksk_from_paths.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import unittest
|
||||
from trustcafeapiwrapper.utils.get_child_spksk_from_paths import get_child_spksk_from_paths
|
||||
class TestGetChildSpkskFromPaths(unittest.TestCase):
|
||||
def test_post_reaction(self):
|
||||
parent_path = '/user/johndoe'
|
||||
item_path = '/post/12345'
|
||||
expected_output = {
|
||||
"pk": "userprofile#johndoe",
|
||||
"sk": "post#12345",
|
||||
"entity": "post",
|
||||
"slug": "12345"
|
||||
}
|
||||
self.assertEqual(get_child_spksk_from_paths(parent_path, item_path), expected_output)
|
||||
|
||||
def test_comment_reaction(self):
|
||||
parent_path = '/post/12345'
|
||||
item_path = '/comment/67890'
|
||||
expected_output = {
|
||||
"pk": "post#12345",
|
||||
"sk": "comment#67890",
|
||||
"entity": "comment",
|
||||
"slug": "67890"
|
||||
}
|
||||
self.assertEqual(get_child_spksk_from_paths(parent_path, item_path), expected_output)
|
||||
34
tests/wrappers/vote.py
Normal file
34
tests/wrappers/vote.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import unittest
|
||||
from trustcafeapiwrapper.wrappers.vote.votecast import votecast
|
||||
class TestVoteCast(unittest.TestCase):
|
||||
def test_vote_cast_to_post(self):
|
||||
vote = 'up'
|
||||
parent_path = '/'
|
||||
item_path = '/post/12345'
|
||||
result = votecast(vote, parent_path, item_path)
|
||||
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertIn("job_function", result)
|
||||
self.assertIn("payload", result)
|
||||
self.assertEqual(result["job_function"], "vote.votecast")
|
||||
self.assertEqual(result["payload"]["vote"], vote)
|
||||
self.assertEqual(result["payload"]["parent"]["pk"], "maintrunk#maintrunk")
|
||||
self.assertEqual(result["payload"]["parent"]["sk"], "post#12345")
|
||||
self.assertEqual(result["payload"]["parent"]["entity"], "post")
|
||||
self.assertEqual(result["payload"]["parent"]["slug"], "12345")
|
||||
|
||||
def test_vote_cast_to_comment(self):
|
||||
vote = 'down'
|
||||
parent_path = '/post/12345'
|
||||
item_path = '/comment/67890'
|
||||
result = votecast(vote, parent_path, item_path)
|
||||
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertIn("job_function", result)
|
||||
self.assertIn("payload", result)
|
||||
self.assertEqual(result["job_function"], "vote.votecast")
|
||||
self.assertEqual(result["payload"]["vote"], vote)
|
||||
self.assertEqual(result["payload"]["parent"]["pk"], "post#12345")
|
||||
self.assertEqual(result["payload"]["parent"]["sk"], "comment#67890")
|
||||
self.assertEqual(result["payload"]["parent"]["entity"], "comment")
|
||||
self.assertEqual(result["payload"]["parent"]["slug"], "67890")
|
||||
Loading…
Add table
Add a link
Reference in a new issue