import os
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'plp_backend.settings')
django.setup()

from rest_framework.test import APIClient
from django.contrib.auth.models import User
from rest_framework_simplejwt.tokens import RefreshToken

# Get or create superuser
user, _ = User.objects.get_or_create(username='admin', defaults={'is_superuser': True, 'is_staff': True})

refresh = RefreshToken.for_user(user)
access_token = str(refresh.access_token)

client = APIClient()
response = client.get('/api/admin/members/', HTTP_AUTHORIZATION=f'Bearer {access_token}')
print("Status Code:", response.status_code)
print("Response:", response.json())
