1.4 KiB
1.4 KiB
User API Test Report
How to Run the Tests
Run all user API tests:
pytest --tb=short tests/api_tests/user/
Test Results Summary
- Total tests collected: 6
- All tests passed.
- Warnings:
- Deprecation warnings from Pydantic/Beanie (upgrade recommended for future compatibility).
Test Case Explanations
test_assign_roles.py
- test_assign_roles_success_by_admin
Admin user can assign a role to a user successfully. - test_assign_roles_fail_by_non_admin
Non-admin user cannot assign roles to other users (permission denied). - test_assign_roles_fail_role_not_found
Assigning a non-existent role to a user fails. - test_assign_roles_fail_empty_role_ids
Assigning with an empty role list fails. - test_assign_roles_fail_empty_user_id
Assigning roles with an empty user ID fails. - test_assign_roles_remove_duplicates
Assigning duplicate role IDs results in de-duplication; the user ends up with a single instance of the role.
Summary
- These tests ensure that only admin users can assign roles to users, and that the system properly handles invalid input and duplicate assignments.
- Each test case is designed to verify both positive and negative scenarios, including permission checks and input validation.
- If you need to add more user management scenarios, add new test cases to this directory and re-run the tests.