import os
import django

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

from django.test import Client

client = Client()

# Test borrower login
print("Testing borrower login...")
response = client.post('/login/', {
    'username': 'borrower1',
    'password': 'borrower123'
})

print(f"Status: {response.status_code}")
if response.status_code == 302:
    print("✓ Borrower login successful!")
    print(f"Redirects to: {response.url}")
elif response.status_code == 200:
    print("✗ Borrower login failed - stayed on login page")
else:
    print(f"✗ Unexpected status: {response.status_code}")

# Test loan officer login
print("\nTesting loan officer login...")
response = client.post('/login/', {
    'username': 'officer1',
    'password': 'officer123'
})

print(f"Status: {response.status_code}")
if response.status_code == 302:
    print("✓ Loan officer login successful!")
    print(f"Redirects to: {response.url}")
elif response.status_code == 200:
    print("✗ Loan officer login failed - stayed on login page")
else:
    print(f"✗ Unexpected status: {response.status_code}")

print("\n✓ All sample users are working correctly!")
