I created some unit tests with basic asserts checking for status codes to get a few tests done and working. The endpoints themselves work flawlessly when I test them individually outside of the Django unit tests using manage.py test test_file
However, I am getting a 401 Unauthorized on all endpoints when I run the tests. I have tried writing in several auth methods to correct the issue but no matter what I try, a 401 is returned.
I have tried adding a force auth function, changing TestCase to APITestCase, and creating a superuser manually in the setUp() for each of my test cases.
All of the solutions I have found online for similar problems still yield the 401, unauthorized error.
Using:
Django 3.2.14
Python 3.10.4
I have also followed the Django Rest API documentation for test cases to the letter. I get 401 errors all the way through.