2024-07-08 07:46:20 -07:00
|
|
|
import zoneinfo
|
|
|
|
|
|
|
|
|
|
import pytest
|
2025-02-26 12:37:33 -08:00
|
|
|
from django.contrib.auth import get_user_model
|
2024-07-08 07:46:20 -07:00
|
|
|
from pytest_django.fixtures import SettingsWrapper
|
2025-02-26 12:37:33 -08:00
|
|
|
from rest_framework.test import APIClient
|
2024-07-08 07:46:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
|
def settings_timezone(settings: SettingsWrapper) -> zoneinfo.ZoneInfo:
|
|
|
|
|
return zoneinfo.ZoneInfo(settings.TIME_ZONE)
|
2025-02-26 12:37:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def rest_api_client():
|
|
|
|
|
"""
|
|
|
|
|
The basic DRF ApiClient
|
|
|
|
|
"""
|
|
|
|
|
yield APIClient()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def authenticated_rest_api_client(rest_api_client: APIClient):
|
|
|
|
|
"""
|
|
|
|
|
The basic DRF ApiClient which has been authenticated
|
|
|
|
|
"""
|
|
|
|
|
UserModel = get_user_model()
|
|
|
|
|
user = UserModel.objects.create_user(username="testuser", password="password")
|
|
|
|
|
rest_api_client.force_authenticate(user=user)
|
|
|
|
|
yield rest_api_client
|