2021-09-05 22:05:29 -08:00
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
2021-09-09 08:51:29 -08:00
|
|
|
from tests.utils.factories import user_registration_factory
|
2021-09-05 22:05:29 -08:00
|
|
|
|
|
|
|
|
|
|
|
class Routes:
|
|
|
|
base = "/api/users/register"
|
|
|
|
auth_token = "/api/auth/token"
|
|
|
|
|
|
|
|
|
|
|
|
def test_user_registration_new_group(api_client: TestClient):
|
2021-09-09 08:51:29 -08:00
|
|
|
registration = user_registration_factory()
|
2021-09-05 22:05:29 -08:00
|
|
|
|
|
|
|
response = api_client.post(Routes.base, json=registration.dict(by_alias=True))
|
|
|
|
assert response.status_code == 201
|
|
|
|
|
|
|
|
# Login
|
2021-09-09 08:51:29 -08:00
|
|
|
form_data = {"username": registration.email, "password": registration.password}
|
2021-09-05 22:05:29 -08:00
|
|
|
|
|
|
|
response = api_client.post(Routes.auth_token, form_data)
|
|
|
|
assert response.status_code == 200
|
|
|
|
token = response.json().get("access_token")
|
|
|
|
|
|
|
|
assert token is not None
|