import os
import django
import sys
import json
from rest_framework.test import APIClient

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.development")
sys.path.append(os.path.join(os.getcwd(), "backend"))
django.setup()

from apps.accounts.models import User
from apps.hr.models import Employee
from apps.organizations.models import Organization

user = User.objects.filter(is_superuser=True).first()
org = Organization.objects.first()
if not user.organization:
    user.organization = org
    user.save()

employee = getattr(user, 'employee_profile', None)
if not employee:
    print("Superuser has no employee profile. Creating one.")
    employee = Employee.objects.create(user=user, organization=org, employee_code="EMP001")

client = APIClient()
client.force_authenticate(user=user)
response = client.post('/api/hr/attendance/check-in/', {
    'mode': 'MANUAL'
}, format='json')

print("Status Code:", response.status_code)
print("Response:", response.data)
