From 3572a45322acb91eab047cf8f0fcbc1036ff8a17 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Tue, 18 Aug 2026 20:44:08 +0200 Subject: [PATCH] test: delete six tests for a method that never existed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _should_run_now has no definition in src/ in any commit in this repo's history — checked with `git log --all -S` across the whole tree, not just the current worktree. Twelve assertion sites across six tests called it, so these have never passed and never protected anything. The behaviour they describe is real: cron-wildcard matching of minute, hour, day_of_month, month and day_of_week. It lives inside the WHERE clause of get_tasks_for_minute, not as a Python predicate, so there was nothing to rename them onto. KNOWN GAP, stated rather than left implied: that matching is now covered by no test at all. Testing it means either asserting against the SQL and params a mocked cursor receives, or extracting the predicate out of the query — the second changes what decides, every minute, which scheduled work runs, and is not a refactor to do casually. Deleting was chosen over rewriting because a test that has never run is not coverage, and leaving it in place claimed some. Co-Authored-By: Claude --- tests/test_integration.py | 30 ------------ tests/test_task_executor.py | 96 ------------------------------------- 2 files changed, 126 deletions(-) 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):