# staff/tests.py
from django.test import TestCase
from django.contrib.auth import get_user_model
from .models import Staff, StaffLeave

User = get_user_model()

class StaffModelTest(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(
            username='teststaff',
            password='testpass123',
            first_name='Test',
            last_name='Staff'
        )
        self.staff = Staff.objects.create(
            user=self.user,
            employee_id='STF-0001',
            role='teacher',
            department='english'
        )
    
    def test_staff_creation(self):
        self.assertEqual(self.staff.employee_id, 'STF-0001')
        self.assertEqual(self.staff.get_full_name(), 'Test Staff')
        self.assertTrue(self.staff.is_teacher)
        self.assertFalse(self.staff.is_admin)
    
    def test_staff_str_method(self):
        self.assertEqual(str(self.staff), 'Test Staff - Teacher (STF-0001)')
    
    def test_auto_employee_id(self):
        new_user = User.objects.create_user(username='newstaff', password='pass')
        new_staff = Staff.objects.create(
            user=new_user,
            role='driver'
        )
        self.assertIsNotNone(new_staff.employee_id)
        self.assertTrue(new_staff.employee_id.startswith('DR-'))