Follow
This commit is contained in:
parent
0bcec8163c
commit
41102d5348
9 changed files with 134 additions and 6 deletions
19
tests/utils/get_entity_from_str.py
Normal file
19
tests/utils/get_entity_from_str.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import unittest
|
||||
from trustcafeapiwrapper.utils.get_entity_from_str import get_entity_from_str
|
||||
|
||||
class TestGetEntityFromStr(unittest.TestCase):
|
||||
def test_branch(self):
|
||||
self.assertEqual(get_entity_from_str('branch'), 'subwiki')
|
||||
|
||||
def test_user(self):
|
||||
self.assertEqual(get_entity_from_str('user'), 'userprofile')
|
||||
|
||||
def test_subwiki(self):
|
||||
self.assertEqual(get_entity_from_str('subwiki'), 'subwiki')
|
||||
|
||||
def test_userprofile(self):
|
||||
self.assertEqual(get_entity_from_str('userprofile'), 'userprofile')
|
||||
|
||||
def test_invalid_entity(self):
|
||||
with self.assertRaises(ValueError):
|
||||
get_entity_from_str('invalidentity')
|
||||
23
tests/wrappers/follow.py
Normal file
23
tests/wrappers/follow.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import unittest
|
||||
from trustcafeapiwrapper.wrappers.follow.follow import follow
|
||||
|
||||
class TestFollow(unittest.TestCase):
|
||||
def test_follow(self):
|
||||
|
||||
result = follow(
|
||||
entity='user',
|
||||
is_following=True,
|
||||
parent_slug='janedoe'
|
||||
)
|
||||
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertIn("job_function", result)
|
||||
self.assertIn("payload", result)
|
||||
self.assertEqual(result["job_function"], "follow.follow")
|
||||
self.assertIsInstance(result["payload"], dict)
|
||||
self.assertIn("isFollowing", result["payload"])
|
||||
self.assertIn("parent", result["payload"])
|
||||
self.assertIn("followType", result["payload"])
|
||||
self.assertIn("preferences", result["payload"])
|
||||
self.assertEqual(result["payload"]["isFollowing"], True)
|
||||
self.assertEqual(result["payload"]["parent"]["pk"], "userprofile#janedoe")
|
||||
Loading…
Add table
Add a link
Reference in a new issue