This commit is contained in:
simonwt 2026-04-16 21:58:31 +01:00
parent 0bcec8163c
commit 41102d5348
9 changed files with 134 additions and 6 deletions

View 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
View 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")