Test basic cache operations.
(results: StressTestResults)
| 68 | |
| 69 | |
| 70 | def test_basic_functionality(results: StressTestResults) -> None: |
| 71 | """Test basic cache operations.""" |
| 72 | print("\n📋 TEST 1: Basic Functionality") |
| 73 | print("-" * 70) |
| 74 | |
| 75 | with tempfile.TemporaryDirectory() as temp_dir: |
| 76 | temp_path = Path(temp_dir) |
| 77 | test_dir = temp_path / "test_files" |
| 78 | cache_dir = temp_path / ".cache" |
| 79 | |
| 80 | files = create_test_files(test_dir, 5) |
| 81 | root = str(test_dir) |
| 82 | cache = HashFingerprintCache(cache_dir, "basic_test") |
| 83 | |
| 84 | # First check should need update |
| 85 | needs_update = cache.check_needs_update(include=_TEST_INCLUDE, root=root) |
| 86 | if needs_update: |
| 87 | results.pass_test("Initial check returns True (cache miss)") |
| 88 | else: |
| 89 | results.fail_test("Initial check returns True", "Got False instead") |
| 90 | |
| 91 | # Mark success |
| 92 | try: |
| 93 | cache.mark_success() |
| 94 | results.pass_test("mark_success() completes without error") |
| 95 | except KeyboardInterrupt as ki: |
| 96 | handle_keyboard_interrupt(ki) |
| 97 | raise |
| 98 | except Exception as e: |
| 99 | results.fail_test("mark_success()", str(e)) |
| 100 | |
| 101 | # Second check should NOT need update |
| 102 | needs_update2 = cache.check_needs_update(include=_TEST_INCLUDE, root=root) |
| 103 | if not needs_update2: |
| 104 | results.pass_test("Second check returns False (cache hit)") |
| 105 | else: |
| 106 | results.fail_test("Second check returns False", "Got True instead") |
| 107 | |
| 108 | # Modify a file |
| 109 | time.sleep(0.05) |
| 110 | files[0].write_text("Modified content\n") |
| 111 | |
| 112 | # Third check should need update |
| 113 | needs_update3 = cache.check_needs_update(include=_TEST_INCLUDE, root=root) |
| 114 | if needs_update3: |
| 115 | results.pass_test("Check after modification returns True") |
| 116 | else: |
| 117 | results.fail_test( |
| 118 | "Check after modification returns True", "Got False instead" |
| 119 | ) |
| 120 | |
| 121 | |
| 122 | def test_file_modification_during_processing(results: StressTestResults) -> None: |
no test coverage detected