Files
sdb2-backend/test_task.py
JSC dc89e45675 Refactor scheduled task repository and schemas for improved type hints and consistency
- Updated type hints from List/Optional to list/None for better readability and consistency across the codebase.
- Refactored import statements for better organization and clarity.
- Enhanced the ScheduledTaskBase schema to use modern type hints.
- Cleaned up unnecessary comments and whitespace in various files.
- Improved error handling and logging in task execution handlers.
- Updated test cases to reflect changes in type hints and ensure compatibility with the new structure.
2025-08-28 23:38:47 +02:00

33 lines
1019 B
Python

#!/usr/bin/env python3
"""Create a test task for scheduler testing."""
import asyncio
from datetime import datetime
from app.core.database import get_session_factory
from app.models.scheduled_task import RecurrenceType, TaskType
from app.repositories.scheduled_task import ScheduledTaskRepository
async def create_test_task():
session_factory = get_session_factory()
async with session_factory() as session:
repo = ScheduledTaskRepository(session)
task_data = {
"name": "Live Test Task",
"task_type": TaskType.PLAY_SOUND,
"scheduled_at": datetime(2025, 8, 28, 15, 21, 0), # 15:21:00 UTC
"timezone": "UTC",
"parameters": {"sound_id": 1},
"user_id": 1,
"recurrence_type": RecurrenceType.NONE,
}
task = await repo.create(task_data)
print(f"Created task: {task.name} (ID: {task.id}) scheduled for {task.scheduled_at}")
if __name__ == "__main__":
asyncio.run(create_test_task())