|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 | from pytest_mock import MockerFixture |
| 9 | +from pydantic import SecretStr, AnyUrl |
9 | 10 |
|
10 | 11 | import psycopg2 |
11 | 12 |
|
@@ -71,7 +72,11 @@ def postgres_cache_config() -> PostgreSQLDatabaseConfiguration: |
71 | 72 | # can be any configuration, becuase tests won't really try to |
72 | 73 | # connect to database |
73 | 74 | return PostgreSQLDatabaseConfiguration( |
74 | | - host="localhost", port=1234, db="database", user="user", password="password" |
| 75 | + host="localhost", |
| 76 | + port=1234, |
| 77 | + db="database", |
| 78 | + user="user", |
| 79 | + password=SecretStr("password"), |
75 | 80 | ) |
76 | 81 |
|
77 | 82 |
|
@@ -158,7 +163,8 @@ def test_connected_when_connection_error( |
158 | 163 | mocker.patch("psycopg2.connect") |
159 | 164 | # simulate connection error |
160 | 165 | cache = PostgresCache(postgres_cache_config_fixture) |
161 | | - cache.connection = ConnectionMock() |
| 166 | + # connection does not have to have proper type |
| 167 | + cache.connection = ConnectionMock() # pyright: ignore |
162 | 168 | assert cache.connection is not None |
163 | 169 | assert cache.connected() is False |
164 | 170 |
|
@@ -282,7 +288,8 @@ def test_insert_or_append_operation_operation_error( |
282 | 288 |
|
283 | 289 | # no operation for @connection decorator |
284 | 290 | cache.connect = lambda: None |
285 | | - cache.connection = ConnectionMock() |
| 291 | + # connection does not have to have proper type |
| 292 | + cache.connection = ConnectionMock() # pyright: ignore |
286 | 293 |
|
287 | 294 | with pytest.raises(CacheError, match="insert_or_append"): |
288 | 295 | cache.insert_or_append(USER_ID_1, CONVERSATION_ID_1, cache_entry_1, False) |
@@ -335,7 +342,8 @@ def test_delete_operation_operation_error( |
335 | 342 |
|
336 | 343 | # no operation for @connection decorator |
337 | 344 | cache.connect = lambda: None |
338 | | - cache.connection = ConnectionMock() |
| 345 | + # connection does not have to have proper type |
| 346 | + cache.connection = ConnectionMock() # pyright: ignore |
339 | 347 |
|
340 | 348 | with pytest.raises(CacheError, match="delete"): |
341 | 349 | cache.delete(USER_ID_1, CONVERSATION_ID_1, False) |
@@ -458,7 +466,9 @@ def test_insert_and_get_with_referenced_documents( |
458 | 466 | mock_cursor = mock_connection.cursor.return_value.__enter__.return_value |
459 | 467 |
|
460 | 468 | # Create a CacheEntry with referenced documents |
461 | | - docs = [ReferencedDocument(doc_title="Test Doc", doc_url="http://example.com/")] |
| 469 | + docs = [ |
| 470 | + ReferencedDocument(doc_title="Test Doc", doc_url=AnyUrl("http://example.com/")) |
| 471 | + ] |
462 | 472 | entry_with_docs = CacheEntry( |
463 | 473 | query="user message", |
464 | 474 | response="AI message", |
|
0 commit comments