Gahyun Son
Posted on November 28, 2024
The error messages.
apple@GH-MacBook-Pro hyunphoto-cbv % docker compose run --rm app sh -c "python manage.py test"
[+] Creating 1/0
β Container hyunphoto-cbv-db-1 Running 0.0s
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
..............FFFWaiting for database...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database available!
.Waiting for database...
Database available!
.
======================================================================
FAIL: test_signup_user_exist_error (user.tests.test_user_api.PublicUserApiTests)
Test signup a user is fail, email already exists.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/user/tests/test_user_api.py", line 47, in test_signup_user_exist_error
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
AssertionError: 403 != 400
======================================================================
FAIL: test_signup_user_password_short_error (user.tests.test_user_api.PublicUserApiTests)
Test signup a user is fail, password is too short.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/user/tests/test_user_api.py", line 58, in test_signup_user_password_short_error
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
AssertionError: 403 != 400
======================================================================
FAIL: test_signup_user_success (user.tests.test_user_api.PublicUserApiTests)
Test creating/signup a user is successful.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/user/tests/test_user_api.py", line 32, in test_signup_user_success
self.assertEqual(res.status_code, status.HTTP_201_CREATED)
AssertionError: 403 != 201
----------------------------------------------------------------------
Ran 19 tests in 8.604s
FAILED (failures=3)
Destroying test database for alias 'default'...
The causes can be
- views.py
- serializers.py
- something else
It was my views.py code.
class CreateUserView(generics.ListCreateAPIView):
serializer_class = UserSerializer
I couldn't believe this situation. Because it worked very well yesterday. I don't know why it doesn't work but I have to figure out.
I have suspicion to permission.
I modified views.py and
class CreateUserView(generics.CreateAPIView):
serializer_class = UserSerializer
permission_classes = [AllowAny]
It fixed.
----------------------------------------------------------------------
Ran 19 tests in 8.788s
OK
Destroying test database for alias 'default'...
I just... still have a question... Why it worked yesterday...?
π πͺ π
π©
Gahyun Son
Posted on November 28, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
beginners Master API Development with Django REST Framework β Learn Django REST Framework for Free!
October 18, 2024