From 358b105f053b743a84f489b47224cef8758d66f7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 19:20:04 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20add=20unit=20test=20for?= =?UTF-8?q?=20db.has=5Fpgvector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new test class `TestHasPgVector` to `tests/test_db_serialization.py` to verify that the `has_pgvector()` function correctly reflects the state of the internal `_pgvector_available` flag in `src/cuba_memorys/db.py`. The test toggles the internal flag and asserts that the function returns the expected value, ensuring it works as intended. Targeted function: `cuba_memorys.db.has_pgvector` Co-authored-by: LeandroPG19 <151863062+LeandroPG19@users.noreply.github.com> --- tests/test_db_serialization.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_db_serialization.py b/tests/test_db_serialization.py index 6535fbe..c561e25 100644 --- a/tests/test_db_serialization.py +++ b/tests/test_db_serialization.py @@ -8,7 +8,26 @@ from decimal import Decimal from uuid import UUID, uuid4 -from cuba_memorys.db import _json_default, serialize, _DB_NAME_PATTERN +from cuba_memorys.db import _json_default, serialize, _DB_NAME_PATTERN, has_pgvector +import cuba_memorys.db + + +class TestHasPgVector: + """Tests for has_pgvector() flag.""" + + def test_has_pgvector_toggle(self) -> None: + """🟢 has_pgvector() correctly reports the state of the global flag.""" + # Save original state + original = cuba_memorys.db._pgvector_available + try: + cuba_memorys.db._pgvector_available = True + assert has_pgvector() is True + + cuba_memorys.db._pgvector_available = False + assert has_pgvector() is False + finally: + # Restore original state + cuba_memorys.db._pgvector_available = original class TestJsonDefault: