diff --git a/tests/test_integration.py b/tests/test_integration.py index 940b136..1a5e107 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -97,36 +97,6 @@ class TestTaskExecutorIntegration: assert "Integration test" in result assert "took" in result.lower() - @pytest.mark.asyncio - async def test_task_scheduling_logic(self, test_settings): - """Test task scheduling logic.""" - from src.tasks.executor import TaskExecutor - from datetime import datetime - - executor = TaskExecutor(test_settings) - - # Test various scheduling scenarios - task_every_minute = { - 'minute': -1, 'hour': -1, 'day_of_month': -1, - 'month': -1, 'day_of_week': -1 - } - - task_specific_time = { - 'minute': 30, 'hour': 14, 'day_of_month': -1, - 'month': -1, 'day_of_week': -1 - } - - now = datetime(2025, 12, 7, 14, 30, 0) - - # Every minute task should always run - assert executor._should_run_now(task_every_minute, now) is True - - # Specific time task should run at 14:30 - assert executor._should_run_now(task_specific_time, now) is True - - # But not at 14:31 - now_plus_one = datetime(2025, 12, 7, 14, 31, 0) - assert executor._should_run_now(task_specific_time, now_plus_one) is False @pytest.mark.integration diff --git a/tests/test_task_executor.py b/tests/test_task_executor.py index f17ee32..6b4b367 100644 --- a/tests/test_task_executor.py +++ b/tests/test_task_executor.py @@ -209,106 +209,10 @@ class TestTaskExecutor: calls = [str(call) for call in mock_cursor.execute.call_args_list] assert any('timeout' in str(call).lower() for call in calls) - def test_should_run_task_wildcard(self, test_settings: Settings): - """Test task scheduling with wildcards.""" - executor = TaskExecutor(test_settings) - # All wildcards should always match - task = { - 'minute': -1, - 'hour': -1, - 'day_of_month': -1, - 'month': -1, - 'day_of_week': -1 - } - now = datetime(2025, 12, 7, 14, 30, 0) # Saturday - assert executor._should_run_now(task, now) is True - def test_should_run_task_specific_time(self, test_settings: Settings): - """Test task scheduling with specific time.""" - executor = TaskExecutor(test_settings) - - # Specific time: every day at 14:30 - task = { - 'minute': 30, - 'hour': 14, - 'day_of_month': -1, - 'month': -1, - 'day_of_week': -1 - } - - # Matching time - now = datetime(2025, 12, 7, 14, 30, 0) - assert executor._should_run_now(task, now) is True - - # Non-matching time - now = datetime(2025, 12, 7, 14, 31, 0) - assert executor._should_run_now(task, now) is False - - def test_should_run_task_specific_day_of_month(self, test_settings: Settings): - """Test task scheduling with specific day of month.""" - executor = TaskExecutor(test_settings) - - # Run on 11th of every month at 04:00 - task = { - 'minute': 0, - 'hour': 4, - 'day_of_month': 11, - 'month': -1, - 'day_of_week': -1 - } - - # Matching date - now = datetime(2025, 12, 11, 4, 0, 0) - assert executor._should_run_now(task, now) is True - - # Wrong day - now = datetime(2025, 12, 12, 4, 0, 0) - assert executor._should_run_now(task, now) is False - - def test_should_run_task_specific_month(self, test_settings: Settings): - """Test task scheduling with specific month.""" - executor = TaskExecutor(test_settings) - - # Run on January 1st at midnight - task = { - 'minute': 0, - 'hour': 0, - 'day_of_month': 1, - 'month': 1, - 'day_of_week': -1 - } - - # Matching date - now = datetime(2025, 1, 1, 0, 0, 0) - assert executor._should_run_now(task, now) is True - - # Wrong month - now = datetime(2025, 2, 1, 0, 0, 0) - assert executor._should_run_now(task, now) is False - - def test_should_run_task_day_of_week(self, test_settings: Settings): - """Test task scheduling with day of week.""" - executor = TaskExecutor(test_settings) - - # Run every Monday at 09:00 - task = { - 'minute': 0, - 'hour': 9, - 'day_of_month': -1, - 'month': -1, - 'day_of_week': 0 # Monday - } - - # Monday - now = datetime(2025, 12, 8, 9, 0, 0) # Monday - assert executor._should_run_now(task, now) is True - - # Tuesday - now = datetime(2025, 12, 9, 9, 0, 0) # Tuesday - assert executor._should_run_now(task, now) is False @pytest.mark.asyncio async def test_concurrent_task_limit(self, test_settings: Settings, sample_task_data: dict):