from django.contrib.auth import get_user_model from django.test import TestCase from rest_framework.test import APIClient from .models import ScheduleEntry class PlanningApiTests(TestCase): def setUp(self): self.client = APIClient() self.admin = get_user_model().objects.create_superuser('admin', password='test-password') def test_public_schedule_is_public(self): ScheduleEntry.objects.create( start_date='2026-10-01', end_date='2026-10-01', start_time='08:00', end_time='12:00', status='busy', ) response = self.client.get('/api/planning/public/schedule/?start=2026-10-01&end=2026-10-07') self.assertEqual(response.status_code, 200) self.assertEqual(len(response.json()), 1) def test_admin_schedule_requires_auth(self): response = self.client.get('/api/planning/schedule/') self.assertEqual(response.status_code, 401)