Я пытаюсь запустить простой пост-тест для моего API, где я регистрирую пользователя. Маршрут работает отлично. Однако мой тест продолжает проваливаться со следующей ошибкой:
E assert 400 == 201
E -400
E +201
src/tests/test_UserView.py:34: AssertionError
Соответствующий код из моего test_UserView.py
размещен ниже.
import pytest, json
@pytest.mark.usefixtures("client")
class TestUserView:
def test_user_creation(self, client):
"""
Test user creation with valid credentials
"""
url = '/v1/users/'
mimetype = 'application/json'
headers = {
'Content-Type': mimetype,
'Accept': mimetype
}
data = {
'username': 'webby',
'email': 'webby@example.com',
'password': 'w3bby12345',
'first_name': 'Mike',
'dob': '1973-03-03',
'last_name': 'Webb',
'city': 'Temple Hills',
'state_provence': 'Maryland',
'country': 'USA'
}
response = client.post(url, data=json.dumps(data), headers=headers)
assert response.content_type == mimetype
assert response.status_code == 201