|
| 1 | +# type: ignore |
1 | 2 | import os |
2 | 3 | import tempfile |
3 | 4 | import hashlib |
|
13 | 14 | class TestContentHashFunctionality: |
14 | 15 | """Test suite for content hash functionality.""" |
15 | 16 |
|
16 | | - def setup_method(self): |
| 17 | + def setup_method(self) -> None: |
17 | 18 | """Setup method called before each test.""" |
18 | 19 | # Stop any existing cocoindex instance |
19 | 20 | try: |
20 | 21 | cocoindex.stop() |
21 | 22 | except: |
22 | 23 | pass |
23 | 24 |
|
24 | | - def teardown_method(self): |
| 25 | + def teardown_method(self) -> None: |
25 | 26 | """Teardown method called after each test.""" |
26 | 27 | # Stop cocoindex instance after each test |
27 | 28 | try: |
28 | 29 | cocoindex.stop() |
29 | 30 | except: |
30 | 31 | pass |
31 | 32 |
|
32 | | - def test_content_hash_with_local_files(self): |
| 33 | + def test_content_hash_with_local_files(self) -> None: |
33 | 34 | """Test that content hash works correctly with local file sources.""" |
34 | 35 | with tempfile.TemporaryDirectory() as temp_dir: |
35 | 36 | # Create test files |
@@ -74,7 +75,7 @@ def process_files( |
74 | 75 | assert result1 == f"processed: {file1_content}" |
75 | 76 | assert result2 == f"processed: {file2_content}" |
76 | 77 |
|
77 | | - def test_content_hash_computation(self): |
| 78 | + def test_content_hash_computation(self) -> None: |
78 | 79 | """Test that content hash is computed correctly.""" |
79 | 80 | # Test content hash computation with known content |
80 | 81 | test_content = "Hello, World!" |
@@ -110,7 +111,7 @@ def hash_test_flow( |
110 | 111 | assert result1 == result2 |
111 | 112 | assert result1 == f"hash_test: {test_content}" |
112 | 113 |
|
113 | | - def test_content_change_detection(self): |
| 114 | + def test_content_change_detection(self) -> None: |
114 | 115 | """Test that content change detection works correctly.""" |
115 | 116 | with tempfile.TemporaryDirectory() as temp_dir: |
116 | 117 | test_file = Path(temp_dir) / "changing_file.txt" |
@@ -154,7 +155,7 @@ def change_detection_flow( |
154 | 155 | assert result2 == f"version: {changed_content}" |
155 | 156 | assert result1 != result2 |
156 | 157 |
|
157 | | - def test_identical_content_different_timestamps(self): |
| 158 | + def test_identical_content_different_timestamps(self) -> None: |
158 | 159 | """Test that identical content with different timestamps is handled correctly.""" |
159 | 160 | with tempfile.TemporaryDirectory() as temp_dir: |
160 | 161 | file1 = Path(temp_dir) / "file1.txt" |
@@ -199,7 +200,7 @@ def timestamp_test_flow( |
199 | 200 | assert result1 == result2 |
200 | 201 | assert result1 == f"content_hash: {content}" |
201 | 202 |
|
202 | | - def test_content_hash_with_binary_data(self): |
| 203 | + def test_content_hash_with_binary_data(self) -> None: |
203 | 204 | """Test content hash functionality with binary data.""" |
204 | 205 | # Create binary test data |
205 | 206 | binary_data = b"\x00\x01\x02\x03\x04\x05\xff\xfe\xfd" |
@@ -233,7 +234,7 @@ def binary_test_flow( |
233 | 234 |
|
234 | 235 | assert f"binary_processed: {len(text_data)} chars" == result |
235 | 236 |
|
236 | | - def test_empty_content_hash(self): |
| 237 | + def test_empty_content_hash(self) -> None: |
237 | 238 | """Test content hash with empty content.""" |
238 | 239 | # Remove database environment variables |
239 | 240 | with patch.dict(os.environ, {}, clear=False): |
@@ -262,7 +263,7 @@ def empty_content_flow( |
262 | 263 | result = empty_content_flow.eval("") |
263 | 264 | assert result == "empty_check: '' (length: 0)" |
264 | 265 |
|
265 | | - def test_large_content_hash(self): |
| 266 | + def test_large_content_hash(self) -> None: |
266 | 267 | """Test content hash with large content.""" |
267 | 268 | # Create large content |
268 | 269 | large_content = "A" * 10000 + "B" * 10000 + "C" * 10000 |
@@ -294,7 +295,7 @@ def large_content_flow( |
294 | 295 | expected = f"large_content: {len(large_content)} chars, starts_with: {large_content[:10]}" |
295 | 296 | assert result == expected |
296 | 297 |
|
297 | | - def test_unicode_content_hash(self): |
| 298 | + def test_unicode_content_hash(self) -> None: |
298 | 299 | """Test content hash with Unicode content.""" |
299 | 300 | # Create Unicode content with various characters |
300 | 301 | unicode_content = "Hello 世界! 🌍 Здравствуй мир! مرحبا بالعالم!" |
@@ -326,7 +327,7 @@ def unicode_flow( |
326 | 327 | expected = f"unicode: {unicode_content} (length: {len(unicode_content)})" |
327 | 328 | assert result == expected |
328 | 329 |
|
329 | | - def test_content_hash_consistency(self): |
| 330 | + def test_content_hash_consistency(self) -> None: |
330 | 331 | """Test that content hash is consistent across multiple runs.""" |
331 | 332 | test_content = "Consistency test content" |
332 | 333 |
|
@@ -367,21 +368,21 @@ def consistency_flow( |
367 | 368 | class TestContentHashIntegration: |
368 | 369 | """Integration tests for content hash with different scenarios.""" |
369 | 370 |
|
370 | | - def setup_method(self): |
| 371 | + def setup_method(self) -> None: |
371 | 372 | """Setup method called before each test.""" |
372 | 373 | try: |
373 | 374 | cocoindex.stop() |
374 | 375 | except: |
375 | 376 | pass |
376 | 377 |
|
377 | | - def teardown_method(self): |
| 378 | + def teardown_method(self) -> None: |
378 | 379 | """Teardown method called after each test.""" |
379 | 380 | try: |
380 | 381 | cocoindex.stop() |
381 | 382 | except: |
382 | 383 | pass |
383 | 384 |
|
384 | | - def test_github_actions_simulation(self): |
| 385 | + def test_github_actions_simulation(self) -> None: |
385 | 386 | """Simulate GitHub Actions scenario where file timestamps change but content doesn't.""" |
386 | 387 | with tempfile.TemporaryDirectory() as temp_dir: |
387 | 388 | # Create a file |
@@ -446,7 +447,7 @@ def code_analysis_flow( |
446 | 447 | expected = "functions: ['def hello_world():']" |
447 | 448 | assert result1 == expected |
448 | 449 |
|
449 | | - def test_incremental_processing_simulation(self): |
| 450 | + def test_incremental_processing_simulation(self) -> None: |
450 | 451 | """Simulate incremental processing where only some files change.""" |
451 | 452 | with tempfile.TemporaryDirectory() as temp_dir: |
452 | 453 | # Create multiple files |
|
0 commit comments