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.
This commit is contained in:
11
test_task.py
11
test_task.py
@@ -5,15 +5,16 @@ 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
|
||||
from app.models.scheduled_task import TaskType, RecurrenceType
|
||||
|
||||
|
||||
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,
|
||||
@@ -23,9 +24,9 @@ async def create_test_task():
|
||||
"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())
|
||||
asyncio.run(create_test_task())
|
||||
|
||||
Reference in New Issue
Block a user