Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ module-root = ""
[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "function"
testpaths = ["test"]

[tool.pyright]
reportUnusedVariable = true
reportUnusedImport = true
reportDuplicateImport = true
File renamed without changes.
2 changes: 1 addition & 1 deletion test/test_add_messages_with_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def test_transaction_rollback_on_error():
result1 = await transcript.add_messages_with_indexing(batch1)
assert result1.messages_added == 1

initial_count = await transcript.messages.size()
_initial_count = await transcript.messages.size()

# Verify the transaction context manager works
try:
Expand Down
2 changes: 0 additions & 2 deletions test/test_conversation_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
TranscriptMessageMeta,
)

from fixtures import embedding_model, temp_db_path


def parse_iso_datetime(iso_string: str) -> datetime:
"""Helper to parse ISO datetime strings to datetime objects."""
Expand Down
1 change: 0 additions & 1 deletion test/test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typeagent.knowpro.interfaces import ScoredSemanticRefOrdinal
from typeagent.podcasts import podcast

from fixtures import really_needs_auth

tests_dir = os.path.dirname(__file__)
root_dir = os.path.dirname(tests_dir)
Expand Down
2 changes: 1 addition & 1 deletion test/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np

from typeagent.aitools.embeddings import AsyncEmbeddingModel
from fixtures import embedding_model, fake_embeddings, fake_embeddings_tiktoken, FakeEmbeddings # type: ignore # Yes it's used!
from conftest import FakeEmbeddings


@pytest.mark.asyncio
Expand Down
2 changes: 0 additions & 2 deletions test/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from typeagent.knowpro.convsettings import ConversationSettings
from typeagent.transcripts.transcript import TranscriptMessage, TranscriptMessageMeta

from fixtures import really_needs_auth


@pytest.mark.asyncio
async def test_create_conversation_minimal():
Expand Down
2 changes: 1 addition & 1 deletion test/test_incremental_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def test_incremental_index_building():

# Add messages with indexing
print("Adding more messages with indexing...")
result2 = await transcript2.add_messages_with_indexing(messages2)
_result2 = await transcript2.add_messages_with_indexing(messages2)

msg_count2 = await transcript2.messages.size()
print(f"Now have {msg_count2} messages total")
Expand Down
1 change: 0 additions & 1 deletion test/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ def test_semantic_ref_serialization():
"""Test serialization and deserialization of SemanticRef using ConcreteEntity."""
# Create a concrete example of knowledge
knowledge = ConcreteEntity(name="ExampleEntity", type=["ExampleType"])
knowledge_type = "entity"

# Define the range
start = TextLocation(message_ordinal=1)
Expand Down
3 changes: 0 additions & 3 deletions test/test_knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.

import pytest
from typing import cast

from typechat import Result, Failure, Success

Expand All @@ -14,8 +13,6 @@
)
from typeagent.knowpro import convknowledge, kplib

from fixtures import really_needs_auth


class MockKnowledgeExtractor:
async def extract(self, text: str) -> Result[kplib.KnowledgeResponse]:
Expand Down
2 changes: 0 additions & 2 deletions test/test_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from mcp.shared.context import RequestContext
from mcp.types import CreateMessageRequestParams, CreateMessageResult, TextContent

from fixtures import really_needs_auth


@pytest.fixture
def server_params() -> StdioServerParameters:
Expand Down
3 changes: 0 additions & 3 deletions test/test_message_text_index_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@

"""Test to verify message text index population in storage providers."""

import asyncio
import tempfile
import os
import pytest
from typeagent.storage import SqliteStorageProvider
from typeagent.storage.memory.messageindex import MessageTextIndex
from typeagent.knowpro.convsettings import MessageTextIndexSettings
from typeagent.knowpro.convsettings import RelatedTermIndexSettings
from typeagent.aitools.vectorbase import TextEmbeddingIndexSettings
from typeagent.aitools.embeddings import AsyncEmbeddingModel, TEST_MODEL_NAME
from typeagent.podcasts.podcast import PodcastMessage, PodcastMessageMeta
from typeagent.aitools.utils import load_dotenv
import numpy as np


@pytest.mark.asyncio
Expand Down
1 change: 0 additions & 1 deletion test/test_message_text_index_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
TextEmbeddingIndexSettings,
)
from typeagent.aitools.embeddings import AsyncEmbeddingModel
from fixtures import embedding_model, needs_auth # Import the fixtures we need


class TestMessageTextIndexSerialization:
Expand Down
5 changes: 1 addition & 4 deletions test/test_messageindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import AsyncMock, MagicMock
from typing import cast

from fixtures import FakeConversation, FakeMessage
from conftest import FakeConversation, FakeMessage
from typeagent.storage.memory.messageindex import (
MessageTextIndex,
build_message_index,
Expand All @@ -20,12 +20,9 @@
)
from typeagent.storage.memory import (
MemoryStorageProvider,
MemoryMessageCollection,
)
from typeagent.knowpro.textlocindex import TextToTextLocationIndex

from fixtures import needs_auth


@pytest.fixture
def mock_text_location_index() -> MagicMock:
Expand Down
2 changes: 0 additions & 2 deletions test/test_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import pytest

from fixtures import really_needs_auth # type: ignore

from typeagent.aitools.utils import create_async_openai_client


Expand Down
2 changes: 0 additions & 2 deletions test/test_podcasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import pytest
from datetime import timezone

from fixtures import really_needs_auth, temp_dir, embedding_model # type: ignore # Yes they are used!

from typeagent.podcasts.podcast import Podcast
from typeagent.knowpro.convsettings import ConversationSettings
from typeagent.knowpro.interfaces import Datetime
Expand Down
3 changes: 0 additions & 3 deletions test/test_property_index_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

"""Test to verify property index population in storage providers."""

import asyncio
import tempfile
import os
import pytest
Expand All @@ -21,8 +20,6 @@
from typeagent.podcasts.podcast import PodcastMessage
from typeagent.storage import SqliteStorageProvider

from fixtures import really_needs_auth


class MockEmbeddingModel(AsyncEmbeddingModel):
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion test/test_propindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from typeagent.storage.memory import MemorySemanticRefCollection

from fixtures import needs_auth, FakeConversation
from conftest import FakeConversation


@pytest.fixture
Expand Down
26 changes: 1 addition & 25 deletions test/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

import pytest

from fixtures import FakeConversation, FakeMessage, FakeTermIndex # type: ignore
from typeagent.aitools.embeddings import AsyncEmbeddingModel, TEST_MODEL_NAME
from typeagent.aitools.vectorbase import TextEmbeddingIndexSettings
from conftest import FakeConversation, FakeMessage, FakeTermIndex
from typeagent.knowpro.collections import (
MatchAccumulator,
SemanticRefAccumulator,
Expand All @@ -14,14 +12,9 @@
TextRangeCollection,
TextRangesInScope,
)
from typeagent.knowpro.convsettings import ConversationSettings
from typeagent.knowpro.interfaces import (
DateRange,
Datetime,
IConversation,
IMessage,
IStorageProvider,
ITermToSemanticRefIndex,
PropertySearchTerm,
Term,
SearchTerm,
Expand All @@ -31,11 +24,6 @@
TextLocation,
Topic,
)
from typeagent.knowpro.kplib import KnowledgeResponse
from typeagent.knowpro.convsettings import MessageTextIndexSettings
from typeagent.knowpro.convsettings import RelatedTermIndexSettings
from typeagent.storage.memory import MemoryStorageProvider
from typeagent.knowpro.convsettings import ConversationSettings
from typeagent.knowpro.query import (
TextRangeSelector,
get_text_range_for_date_range,
Expand All @@ -52,31 +40,19 @@
MatchSearchTermExpr,
MatchPropertySearchTermExpr,
GetScopeExpr,
get_text_range_for_date_range,
get_matching_term_for_text,
match_search_term_to_text,
match_search_term_to_one_of_text,
match_entity_name_or_type,
lookup_knowledge_type,
)
from typeagent.storage.memory.propindex import PropertyIndex
from typeagent.storage.memory import (
MemoryMessageCollection,
MemorySemanticRefCollection,
)

from fixtures import needs_auth


def downcast[T](cls: type[T], obj: object) -> T:
"""Downcast an object to a specific type."""
assert isinstance(obj, cls), f"Expected type {cls}, but got {type(obj)}"
return obj


from fixtures import needs_auth # type: ignore


def make_semantic_ref(ordinal: int, text_range: TextRange):
return SemanticRef(
semantic_ref_ordinal=ordinal,
Expand Down
3 changes: 0 additions & 3 deletions test/test_query_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@

from typeagent import create_conversation
from typeagent.aitools.embeddings import AsyncEmbeddingModel, TEST_MODEL_NAME
from typeagent.aitools.utils import load_dotenv
from typeagent.knowpro.convsettings import ConversationSettings
from typeagent.transcripts.transcript import TranscriptMessage, TranscriptMessageMeta

from fixtures import really_needs_auth


@pytest.mark.asyncio
async def test_query_method_basic(really_needs_auth: None):
Expand Down
2 changes: 0 additions & 2 deletions test/test_related_terms_index_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from typeagent.podcasts.podcast import PodcastMessage, PodcastMessageMeta
from typeagent.storage import SqliteStorageProvider

from fixtures import really_needs_auth


@pytest.mark.asyncio
async def test_related_terms_index_population_from_database(really_needs_auth):
Expand Down
3 changes: 0 additions & 3 deletions test/test_reltermsindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
from typeagent.storage.memory import MemoryStorageProvider
from typeagent.storage import SqliteStorageProvider

# Test fixtures
from fixtures import needs_auth, really_needs_auth, embedding_model, temp_db_path


@pytest_asyncio.fixture(params=["memory", "sqlite"])
async def related_terms_index(
Expand Down
7 changes: 0 additions & 7 deletions test/test_searchlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
import pytest

from typeagent.knowpro.interfaces import (
KnowledgePropertyName,
PropertySearchTerm,
ScoredSemanticRefOrdinal,
SearchTerm,
SearchTermGroup,
SemanticRef,
Term,
TextLocation,
TextRange,
)
from typeagent.storage.memory.propindex import PropertyNames
from typeagent.knowpro.searchlib import (
Expand All @@ -27,7 +21,6 @@
create_search_terms,
create_tag_search_term_group,
create_topic_search_term_group,
get_semantic_refs_from_scored_ordinals,
)


Expand Down
9 changes: 1 addition & 8 deletions test/test_secindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@

import pytest

from fixtures import (
memory_storage,
needs_auth,
embedding_model,
from conftest import (
FakeConversation,
FakeMessage,
) # Import the storage fixture
from typeagent.aitools.embeddings import AsyncEmbeddingModel, TEST_MODEL_NAME
from typeagent.aitools.vectorbase import TextEmbeddingIndexSettings
from typeagent.knowpro.convsettings import ConversationSettings
from typeagent.knowpro.convsettings import MessageTextIndexSettings
from typeagent.knowpro.convsettings import RelatedTermIndexSettings
from typeagent.storage.memory.timestampindex import TimestampToTextRangeIndex
from typeagent.storage.memory import MemoryStorageProvider
Expand All @@ -24,11 +20,8 @@
)
from typeagent.storage.memory import (
MemoryMessageCollection as MemoryMessageCollection,
MemorySemanticRefCollection,
)

from fixtures import needs_auth # type: ignore # Yes it is used!


@pytest.fixture
def simple_conversation() -> FakeConversation:
Expand Down
1 change: 0 additions & 1 deletion test/test_secindex_storage_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Test that ConversationSecondaryIndexes now uses storage provider properly
import pytest

from fixtures import needs_auth, memory_storage, embedding_model # type: ignore # It's used!
from typeagent.aitools.embeddings import AsyncEmbeddingModel, TEST_MODEL_NAME
from typeagent.aitools.vectorbase import TextEmbeddingIndexSettings
from typeagent.knowpro.convsettings import RelatedTermIndexSettings
Expand Down
2 changes: 0 additions & 2 deletions test/test_semrefindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# TypeAgent imports
from typeagent.aitools.embeddings import AsyncEmbeddingModel
from typeagent.aitools.vectorbase import TextEmbeddingIndexSettings
from typeagent.storage.memory import MemorySemanticRefCollection
from typeagent.knowpro.interfaces import (
Topic,
IMessage,
Expand All @@ -32,7 +31,6 @@
from typeagent.storage import SqliteStorageProvider

# Test fixtures
from fixtures import needs_auth, embedding_model, temp_db_path


@pytest_asyncio.fixture(params=["memory", "sqlite"])
Expand Down
1 change: 0 additions & 1 deletion test/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pathlib import Path
from typing import Any, cast

from typeagent.aitools.embeddings import NormalizedEmbeddings
from typeagent.knowpro.serialization import (
serialize_object,
deserialize_object,
Expand Down
4 changes: 1 addition & 3 deletions test/test_sqlite_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
from typeagent.storage.sqlite.semrefindex import SqliteTermToSemanticRefIndex
from typeagent.storage.sqlite.timestampindex import SqliteTimestampToTextRangeIndex

from fixtures import needs_auth, embedding_model, temp_db_path


@pytest.fixture
def embedding_settings(
Expand Down Expand Up @@ -738,7 +736,7 @@ async def test_message_text_index_basic(
assert results == []

# Create some mock messages for testing
from fixtures import FakeMessage
from conftest import FakeMessage
from typeagent.knowpro.interfaces import IMessage

messages: list[IMessage] = [
Expand Down
Loading
Loading