Skip to content

Commit 8eccb07

Browse files
committed
refactor: add type hints to test methods in test_content_hash.py
1 parent ef7b5d6 commit 8eccb07

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

python/cocoindex/tests/test_content_hash.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
import os
23
import tempfile
34
import hashlib
@@ -13,23 +14,23 @@
1314
class TestContentHashFunctionality:
1415
"""Test suite for content hash functionality."""
1516

16-
def setup_method(self):
17+
def setup_method(self) -> None:
1718
"""Setup method called before each test."""
1819
# Stop any existing cocoindex instance
1920
try:
2021
cocoindex.stop()
2122
except:
2223
pass
2324

24-
def teardown_method(self):
25+
def teardown_method(self) -> None:
2526
"""Teardown method called after each test."""
2627
# Stop cocoindex instance after each test
2728
try:
2829
cocoindex.stop()
2930
except:
3031
pass
3132

32-
def test_content_hash_with_local_files(self):
33+
def test_content_hash_with_local_files(self) -> None:
3334
"""Test that content hash works correctly with local file sources."""
3435
with tempfile.TemporaryDirectory() as temp_dir:
3536
# Create test files
@@ -74,7 +75,7 @@ def process_files(
7475
assert result1 == f"processed: {file1_content}"
7576
assert result2 == f"processed: {file2_content}"
7677

77-
def test_content_hash_computation(self):
78+
def test_content_hash_computation(self) -> None:
7879
"""Test that content hash is computed correctly."""
7980
# Test content hash computation with known content
8081
test_content = "Hello, World!"
@@ -110,7 +111,7 @@ def hash_test_flow(
110111
assert result1 == result2
111112
assert result1 == f"hash_test: {test_content}"
112113

113-
def test_content_change_detection(self):
114+
def test_content_change_detection(self) -> None:
114115
"""Test that content change detection works correctly."""
115116
with tempfile.TemporaryDirectory() as temp_dir:
116117
test_file = Path(temp_dir) / "changing_file.txt"
@@ -154,7 +155,7 @@ def change_detection_flow(
154155
assert result2 == f"version: {changed_content}"
155156
assert result1 != result2
156157

157-
def test_identical_content_different_timestamps(self):
158+
def test_identical_content_different_timestamps(self) -> None:
158159
"""Test that identical content with different timestamps is handled correctly."""
159160
with tempfile.TemporaryDirectory() as temp_dir:
160161
file1 = Path(temp_dir) / "file1.txt"
@@ -199,7 +200,7 @@ def timestamp_test_flow(
199200
assert result1 == result2
200201
assert result1 == f"content_hash: {content}"
201202

202-
def test_content_hash_with_binary_data(self):
203+
def test_content_hash_with_binary_data(self) -> None:
203204
"""Test content hash functionality with binary data."""
204205
# Create binary test data
205206
binary_data = b"\x00\x01\x02\x03\x04\x05\xff\xfe\xfd"
@@ -233,7 +234,7 @@ def binary_test_flow(
233234

234235
assert f"binary_processed: {len(text_data)} chars" == result
235236

236-
def test_empty_content_hash(self):
237+
def test_empty_content_hash(self) -> None:
237238
"""Test content hash with empty content."""
238239
# Remove database environment variables
239240
with patch.dict(os.environ, {}, clear=False):
@@ -262,7 +263,7 @@ def empty_content_flow(
262263
result = empty_content_flow.eval("")
263264
assert result == "empty_check: '' (length: 0)"
264265

265-
def test_large_content_hash(self):
266+
def test_large_content_hash(self) -> None:
266267
"""Test content hash with large content."""
267268
# Create large content
268269
large_content = "A" * 10000 + "B" * 10000 + "C" * 10000
@@ -294,7 +295,7 @@ def large_content_flow(
294295
expected = f"large_content: {len(large_content)} chars, starts_with: {large_content[:10]}"
295296
assert result == expected
296297

297-
def test_unicode_content_hash(self):
298+
def test_unicode_content_hash(self) -> None:
298299
"""Test content hash with Unicode content."""
299300
# Create Unicode content with various characters
300301
unicode_content = "Hello 世界! 🌍 Здравствуй мир! مرحبا بالعالم!"
@@ -326,7 +327,7 @@ def unicode_flow(
326327
expected = f"unicode: {unicode_content} (length: {len(unicode_content)})"
327328
assert result == expected
328329

329-
def test_content_hash_consistency(self):
330+
def test_content_hash_consistency(self) -> None:
330331
"""Test that content hash is consistent across multiple runs."""
331332
test_content = "Consistency test content"
332333

@@ -367,21 +368,21 @@ def consistency_flow(
367368
class TestContentHashIntegration:
368369
"""Integration tests for content hash with different scenarios."""
369370

370-
def setup_method(self):
371+
def setup_method(self) -> None:
371372
"""Setup method called before each test."""
372373
try:
373374
cocoindex.stop()
374375
except:
375376
pass
376377

377-
def teardown_method(self):
378+
def teardown_method(self) -> None:
378379
"""Teardown method called after each test."""
379380
try:
380381
cocoindex.stop()
381382
except:
382383
pass
383384

384-
def test_github_actions_simulation(self):
385+
def test_github_actions_simulation(self) -> None:
385386
"""Simulate GitHub Actions scenario where file timestamps change but content doesn't."""
386387
with tempfile.TemporaryDirectory() as temp_dir:
387388
# Create a file
@@ -446,7 +447,7 @@ def code_analysis_flow(
446447
expected = "functions: ['def hello_world():']"
447448
assert result1 == expected
448449

449-
def test_incremental_processing_simulation(self):
450+
def test_incremental_processing_simulation(self) -> None:
450451
"""Simulate incremental processing where only some files change."""
451452
with tempfile.TemporaryDirectory() as temp_dir:
452453
# Create multiple files

0 commit comments

Comments
 (0)