mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-24 16:57:30 +00:00
Add field info to user serializer (#7518)
* Add field info to user serializer * Bump API version * Adjust metadata translation lookup * Improve field metadata introspection * Add unit test
This commit is contained in:
1 parent
c1b2cbef5e
commit
f67147587a
4 files changed
+74
-7
No files matched your search
@@ -12,6 +12,29 @@ from users.models import ApiToken
|
||||
class UserAPITests(InvenTreeAPITestCase):
|
||||
"""Tests for user API endpoints."""
|
||||
|
||||
def test_user_options(self):
|
||||
"""Tests for the User OPTIONS request."""
|
||||
self.assignRole('admin.add')
|
||||
response = self.options(reverse('api-user-list'), expected_code=200)
|
||||
|
||||
fields = response.data['actions']['POST']
|
||||
|
||||
# Check some of the field values
|
||||
self.assertEqual(fields['username']['label'], 'Username')
|
||||
|
||||
self.assertEqual(fields['email']['label'], 'Email')
|
||||
self.assertEqual(fields['email']['help_text'], 'Email address of the user')
|
||||
|
||||
self.assertEqual(fields['is_active']['label'], 'Active')
|
||||
self.assertEqual(
|
||||
fields['is_active']['help_text'], 'Is this user account active'
|
||||
)
|
||||
|
||||
self.assertEqual(fields['is_staff']['label'], 'Staff')
|
||||
self.assertEqual(
|
||||
fields['is_staff']['help_text'], 'Does this user have staff permissions'
|
||||
)
|
||||
|
||||
def test_user_api(self):
|
||||
"""Tests for User API endpoints."""
|
||||
response = self.get(reverse('api-user-list'), expected_code=200)
|
||||
|
||||
Reference in new issue
Block a user