Tested and fixed trust createorupdate

This commit is contained in:
simonwt 2026-04-07 21:54:52 +01:00
parent 255d6ef37b
commit 766ff5b69d
11 changed files with 100 additions and 4 deletions

View file

@ -0,0 +1,8 @@
import unittest
from trustcafeapiwrapper.utils.get_user_slug_from_path import get_user_slug_from_path
class TestGetUserSlugFromPath(unittest.TestCase):
def test_get_user_slug_from_path(self):
# Test with a valid user path
self.assertEqual(get_user_slug_from_path('/user/johndoe'), 'johndoe')

View file

@ -0,0 +1,11 @@
import unittest
from trustcafeapiwrapper.utils.get_userprofile_pksk_from_slug import get_userprofile_pksk_from_slug
class TestGetUserprofilePkskFromSlug(unittest.TestCase):
def test_get_userprofile_pksk_from_slug(self):
slug = 'testuser'
expected_result = {
"pk": "userprofile#testuser",
"sk": "userprofile#testuser"
}
self.assertEqual(get_userprofile_pksk_from_slug(slug), expected_result)

15
tests/wrappers/trust.py Normal file
View file

@ -0,0 +1,15 @@
import unittest
from trustcafeapiwrapper.wrappers.trust.trust import trust
class TestTrustCreateOrUpdate(unittest.TestCase):
def test_trust(self):
trustLevel = 100
userprofile_path = '/user/johndoe'
result = trust(trustLevel, userprofile_path)
self.assertIsInstance(result, dict)
self.assertIn("job_function", result)
self.assertIn("payload", result)
self.assertEqual(result["job_function"], "trust.createorupdate")
self.assertEqual(result["payload"]["trustLevel"], trustLevel)
self.assertEqual(result["payload"]["parentSlug"], "johndoe")