Personal AI, On Personal Devices
Python
style: fix line length violations in connector tests
krypticmousee3e9a70181d2
diff --git a/tests/connectors/test_notion.py b/tests/connectors/test_notion.pyindex c9f3a9ae..aec24694 100644--- a/tests/connectors/test_notion.py+++ b/tests/connectors/test_notion.py@@ -148,9 +148,18 @@ def test_render_blocks_to_markdown() -> None:from openjarvis.connectors.notion import _render_blocks_to_markdown # noqa: PLC0415blocks = [- {"type": "paragraph", "paragraph": {"rich_text": [{"plain_text": "Para text"}]}},- {"type": "heading_1", "heading_1": {"rich_text": [{"plain_text": "H1 Title"}]}},- {"type": "heading_2", "heading_2": {"rich_text": [{"plain_text": "H2 Title"}]}},+ {+ "type": "paragraph",+ "paragraph": {"rich_text": [{"plain_text": "Para text"}]},+ },+ {+ "type": "heading_1",+ "heading_1": {"rich_text": [{"plain_text": "H1 Title"}]},+ },+ {+ "type": "heading_2",+ "heading_2": {"rich_text": [{"plain_text": "H2 Title"}]},+ },{"type": "heading_3", "heading_3": {"rich_text": [{"plain_text": "H3 Title"}]}},{"type": "bulleted_list_item",@@ -162,7 +171,10 @@ def test_render_blocks_to_markdown() -> None:},{"type": "to_do",- "to_do": {"rich_text": [{"plain_text": "Unchecked task"}], "checked": False},+ "to_do": {+ "rich_text": [{"plain_text": "Unchecked task"}],+ "checked": False,+ },},{"type": "to_do",diff --git a/tests/connectors/test_store.py b/tests/connectors/test_store.pyindex 90700dfe..3b0b7eca 100644--- a/tests/connectors/test_store.py+++ b/tests/connectors/test_store.py@@ -2,7 +2,6 @@from __future__ import annotations-import timefrom datetime import datetime, timezonefrom pathlib import Path@@ -10,7 +9,6 @@ import pytestfrom openjarvis.connectors.store import KnowledgeStore-# ---------------------------------------------------------------------------# Helpers# ---------------------------------------------------------------------------@@ -54,7 +52,12 @@ def ks(tmp_path: Path) -> KnowledgeStore:def test_store_and_retrieve_basic(ks: KnowledgeStore) -> None:"""Stored content can be retrieved by a matching query."""- _store(ks, content="The quick brown fox jumps over the lazy dog", source="notes", doc_type="note")+ _store(+ ks,+ content="The quick brown fox jumps over the lazy dog",+ source="notes",+ doc_type="note",+ )results = ks.retrieve("quick brown fox", top_k=5)assert len(results) >= 1assert "fox" in results[0].content.lower() or "quick" in results[0].content.lower()@@ -64,7 +67,12 @@ def test_store_and_retrieve_basic(ks: KnowledgeStore) -> None:def test_retrieve_filter_by_source(ks: KnowledgeStore) -> None:"""retrieve() with source= returns only chunks from that source."""_store(ks, content="Email about project alpha", source="gmail", doc_type="email")- _store(ks, content="Note about project alpha progress", source="obsidian", doc_type="note")+ _store(+ ks,+ content="Note about project alpha progress",+ source="obsidian",+ doc_type="note",+ )gmail_results = ks.retrieve("project alpha", top_k=10, source="gmail")for r in gmail_results:@@ -80,8 +88,18 @@ def test_retrieve_filter_by_source(ks: KnowledgeStore) -> None:def test_retrieve_filter_by_doc_type(ks: KnowledgeStore) -> None:"""retrieve() with doc_type= filters correctly."""- _store(ks, content="Meeting notes from Monday", source="calendar", doc_type="meeting")- _store(ks, content="Meeting email received Tuesday", source="gmail", doc_type="email")+ _store(+ ks,+ content="Meeting notes from Monday",+ source="calendar",+ doc_type="meeting",+ )+ _store(+ ks,+ content="Meeting email received Tuesday",+ source="gmail",+ doc_type="email",+ )meeting_results = ks.retrieve("meeting", top_k=10, doc_type="meeting")for r in meeting_results:@@ -97,10 +115,24 @@ def test_retrieve_filter_by_doc_type(ks: KnowledgeStore) -> None:def test_retrieve_filter_by_author(ks: KnowledgeStore) -> None:"""retrieve() with author= filters correctly."""- _store(ks, content="Alice wrote about machine learning research", source="gmail", doc_type="email", author="[email protected]")- _store(ks, content="Bob wrote about machine learning deployment", source="gmail", doc_type="email", author="[email protected]")+ _store(+ ks,+ content="Alice wrote about machine learning research",+ source="gmail",+ doc_type="email",+ author="[email protected]",+ )+ _store(+ ks,+ content="Bob wrote about machine learning deployment",+ source="gmail",+ doc_type="email",+ author="[email protected]",+ )- alice_results = ks.retrieve("machine learning", top_k=10, author="[email protected]")+ alice_results = ks.retrieve(+ "machine learning", top_k=10, author="[email protected]"+ )for r in alice_results:assert r.metadata.get("author") == "[email protected]"@@ -132,9 +164,27 @@ def test_retrieve_filter_by_timestamp_since(ks: KnowledgeStore) -> None:def test_delete_by_doc_id(ks: KnowledgeStore) -> None:"""delete() removes all chunks with matching doc_id."""doc_id = "test:doc:001"- _store(ks, content="First chunk of the document", source="notes", doc_id=doc_id, chunk_index=0)- _store(ks, content="Second chunk of the document", source="notes", doc_id=doc_id, chunk_index=1)- _store(ks, content="Other document content", source="notes", doc_id="other:doc:001", chunk_index=0)+ _store(+ ks,+ content="First chunk of the document",+ source="notes",+ doc_id=doc_id,+ chunk_index=0,+ )+ _store(+ ks,+ content="Second chunk of the document",+ source="notes",+ doc_id=doc_id,+ chunk_index=1,+ )+ _store(+ ks,+ content="Other document content",+ source="notes",+ doc_id="other:doc:001",+ chunk_index=0,+ )# Confirm items are storedbefore = ks.retrieve("document", top_k=10)@@ -212,7 +262,11 @@ def test_retrieve_empty_store(ks: KnowledgeStore) -> None:def test_retrieve_top_k_respected(ks: KnowledgeStore) -> None:"""top_k limits the number of returned results."""for i in range(10):- _store(ks, content=f"Research document number {i} about topic X", source="notes")+ _store(+ ks,+ content=f"Research document number {i} about topic X",+ source="notes",+ )results = ks.retrieve("research topic", top_k=3)assert len(results) <= 3@@ -231,8 +285,18 @@ def test_retrieve_filter_by_until(ks: KnowledgeStore) -> None:new_ts = datetime(2025, 6, 1, tzinfo=timezone.utc)cutoff = datetime(2024, 1, 1, tzinfo=timezone.utc)- _store(ks, content="Old quarterly report analysis", source="notes", timestamp=old_ts)- _store(ks, content="New quarterly report analysis", source="notes", timestamp=new_ts)+ _store(+ ks,+ content="Old quarterly report analysis",+ source="notes",+ timestamp=old_ts,+ )+ _store(+ ks,+ content="New quarterly report analysis",+ source="notes",+ timestamp=new_ts,+ )results = ks.retrieve("quarterly report", top_k=10, until=cutoff)for r in results:diff --git a/tests/connectors/test_sync_engine.py b/tests/connectors/test_sync_engine.pyindex 2d202968..5b82709d 100644--- a/tests/connectors/test_sync_engine.py+++ b/tests/connectors/test_sync_engine.py@@ -13,7 +13,6 @@ from openjarvis.connectors.pipeline import IngestionPipelinefrom openjarvis.connectors.store import KnowledgeStorefrom openjarvis.connectors.sync_engine import SyncEngine-# ---------------------------------------------------------------------------# StubConnector test helper# ---------------------------------------------------------------------------@@ -54,7 +53,9 @@ class StubConnector(BaseConnector):# ----------------------------------------------------------------------------def _make_doc(doc_id: str, source: str = "stub", content: str = "Test content.") -> Document:+def _make_doc(+ doc_id: str, source: str = "stub", content: str = "Test content."+) -> Document:return Document(doc_id=doc_id,source=source,@@ -93,7 +94,10 @@ def engine(pipeline: IngestionPipeline, tmp_path: Path) -> SyncEngine:def test_sync_connector(engine: SyncEngine, store: KnowledgeStore) -> None:"""StubConnector yields 5 docs; all are ingested and retrievable."""- docs = [_make_doc(f"doc:{i}", content=f"Unique content for document {i}") for i in range(5)]+ docs = [+ _make_doc(f"doc:{i}", content=f"Unique content for document {i}")+ for i in range(5)+ ]connector = StubConnector(docs)items = engine.sync(connector)@@ -141,7 +145,7 @@ def test_sync_status_for_unsynced(engine: SyncEngine) -> None:def test_sync_multiple_connectors(pipeline: IngestionPipeline, store: KnowledgeStore, tmp_path: Path) -> None:- """Two connectors with different sources can be filtered independently in the store."""+ """Two connectors with different sources can be filtered independently."""class StubConnectorA(StubConnector):connector_id = "stub_a"@@ -149,8 +153,14 @@ def test_sync_multiple_connectors(class StubConnectorB(StubConnector):connector_id = "stub_b"- docs_a = [_make_doc(f"a:doc:{i}", source="source_a", content=f"Alpha content {i}") for i in range(3)]- docs_b = [_make_doc(f"b:doc:{i}", source="source_b", content=f"Beta content {i}") for i in range(4)]+ docs_a = [+ _make_doc(f"a:doc:{i}", source="source_a", content=f"Alpha content {i}")+ for i in range(3)+ ]+ docs_b = [+ _make_doc(f"b:doc:{i}", source="source_b", content=f"Beta content {i}")+ for i in range(4)+ ]engine = SyncEngine(pipeline, state_db=str(tmp_path / "multi_sync_state.db"))