diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9448f252..88e21128 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,13 +86,13 @@ jobs: shell: bash if: matrix.task == 'check' run: | - uv run pyright src test tools gmail + uv run pyright src tests tools gmail - name: Run Format shell: bash if: matrix.task == 'format' run: | - uv run black -tpy312 -tpy313 -tpy314 src test tools gmail demo --check + uv run black -tpy312 -tpy313 -tpy314 src tests tools gmail demo --check - name: Login to Azure if: matrix.task == 'test' diff --git a/Makefile b/Makefile index 6f363fe9..c3382c49 100644 --- a/Makefile +++ b/Makefile @@ -8,12 +8,12 @@ all: venv format check test build .PHONY: format format: venv - .venv/bin/isort src test tools gmail demo $(FLAGS) - .venv/bin/black -tpy312 -tpy313 -tpy314 src test tools gmail demo $(FLAGS) + .venv/bin/isort src tests tools gmail demo $(FLAGS) + .venv/bin/black -tpy312 -tpy313 -tpy314 src tests tools gmail demo $(FLAGS) .PHONY: check check: venv - .venv/bin/pyright --pythonpath .venv/bin/python src test tools gmail + .venv/bin/pyright --pythonpath .venv/bin/python src tests tools gmail .PHONY: test test: venv @@ -88,7 +88,7 @@ help: @echo "make all # venv, format, check, test, build" @echo "make format # Run isort and black" @echo "make check # Run pyright" - @echo "make test # Run pytest (tests are in test/)" + @echo "make test # Run pytest (tests are in tests/)" @echo "make coverage # Run tests with coverage" @echo "make build # Build the wheel (under dist/)" @echo "make demo # python tools/query.py (interactive)" diff --git a/make.bat b/make.bat index cdf1f681..d4a5dfb2 100644 --- a/make.bat +++ b/make.bat @@ -26,14 +26,14 @@ goto help :format if not exist ".venv\" call make.bat venv echo Formatting code... -.venv\Scripts\isort src test tools gmail demo -.venv\Scripts\black src test tools gmail demo +.venv\Scripts\isort src tests tools gmail demo +.venv\Scripts\black src tests tools gmail demo goto end :check if not exist ".venv\" call make.bat venv echo Running type checks... -.venv\Scripts\pyright --pythonpath .venv\Scripts\python src test tools gmail demo +.venv\Scripts\pyright --pythonpath .venv\Scripts\python src tests tools gmail demo goto end :test diff --git a/pyproject.toml b/pyproject.toml index dac6ecc6..5376339b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ module-root = "src" [tool.pytest.ini_options] asyncio_default_fixture_loop_scope = "function" -testpaths = ["test"] +testpaths = ["tests"] [tool.pyright] reportUnusedVariable = true @@ -83,7 +83,7 @@ force_sort_within_sections = true sections = ["FUTURE", "STDLIB", "THIRDPARTY", "AI", "FIRSTPARTY", "LOCALFOLDER"] known_ai = ["mcp", "openai", "pydantic", "pydantic_ai", "tiktoken", "typechat"] -known_first_party = ["typeagent", "test", "tools", "gmail", "demo"] +known_first_party = ["typeagent", "tests", "tools", "gmail", "demo"] known_local_folder = ["conftest"] [dependency-groups] diff --git a/test/conftest.py b/tests/test/conftest.py similarity index 100% rename from test/conftest.py rename to tests/test/conftest.py diff --git a/test/test_add_messages_with_indexing.py b/tests/test/test_add_messages_with_indexing.py similarity index 100% rename from test/test_add_messages_with_indexing.py rename to tests/test/test_add_messages_with_indexing.py diff --git a/test/test_auth.py b/tests/test/test_auth.py similarity index 100% rename from test/test_auth.py rename to tests/test/test_auth.py diff --git a/test/test_collections.py b/tests/test/test_collections.py similarity index 100% rename from test/test_collections.py rename to tests/test/test_collections.py diff --git a/test/test_conversation_metadata.py b/tests/test/test_conversation_metadata.py similarity index 100% rename from test/test_conversation_metadata.py rename to tests/test/test_conversation_metadata.py diff --git a/test/test_demo.py b/tests/test/test_demo.py similarity index 100% rename from test/test_demo.py rename to tests/test/test_demo.py diff --git a/test/test_embedding_consistency.py b/tests/test/test_embedding_consistency.py similarity index 100% rename from test/test_embedding_consistency.py rename to tests/test/test_embedding_consistency.py diff --git a/test/test_embeddings.py b/tests/test/test_embeddings.py similarity index 98% rename from test/test_embeddings.py rename to tests/test/test_embeddings.py index 4c02a1fa..47ce7e8a 100644 --- a/test/test_embeddings.py +++ b/tests/test/test_embeddings.py @@ -9,8 +9,13 @@ import openai from typeagent.aitools.embeddings import AsyncEmbeddingModel -from conftest import embedding_model # type: ignore # Magic, prevents side effects of mocking -from conftest import FakeEmbeddings + +from conftest import ( + embedding_model, # type: ignore # Magic, prevents side effects of mocking +) +from conftest import ( + FakeEmbeddings, +) @pytest.mark.asyncio diff --git a/test/test_factory.py b/tests/test/test_factory.py similarity index 100% rename from test/test_factory.py rename to tests/test/test_factory.py diff --git a/test/test_incremental_index.py b/tests/test/test_incremental_index.py similarity index 96% rename from test/test_incremental_index.py rename to tests/test/test_incremental_index.py index f5be82d9..077db4ba 100644 --- a/test/test_incremental_index.py +++ b/tests/test/test_incremental_index.py @@ -18,6 +18,9 @@ ) from typeagent.transcripts.transcript_ingest import ingest_vtt_transcript +tests_dir = os.path.dirname(__file__) +root_dir = os.path.dirname(tests_dir) + @pytest.mark.asyncio async def test_incremental_index_building(): @@ -141,8 +144,9 @@ async def test_incremental_index_with_vtt_files(): # First VTT file ingestion print("\n=== Import first VTT file ===") # Import the first transcript + DEFAULT_FILE = os.path.join(root_dir, "testdata", "Confuse-A-Cat.vtt") transcript1 = await ingest_vtt_transcript( - "testdata/Confuse-A-Cat.vtt", + DEFAULT_FILE, settings, dbname=db_path, ) @@ -165,8 +169,9 @@ async def test_incremental_index_with_vtt_files(): settings2.semantic_ref_index_settings.auto_extract_knowledge = False # Ingest the second transcript + DEFAULT_FILE = os.path.join(root_dir, "testdata", "Parrot_Sketch.vtt") transcript2 = await ingest_vtt_transcript( - "testdata/Parrot_Sketch.vtt", + DEFAULT_FILE, settings2, dbname=db_path, ) diff --git a/test/test_interfaces.py b/tests/test/test_interfaces.py similarity index 100% rename from test/test_interfaces.py rename to tests/test/test_interfaces.py diff --git a/test/test_knowledge.py b/tests/test/test_knowledge.py similarity index 100% rename from test/test_knowledge.py rename to tests/test/test_knowledge.py diff --git a/test/test_kplib.py b/tests/test/test_kplib.py similarity index 100% rename from test/test_kplib.py rename to tests/test/test_kplib.py diff --git a/test/test_mcp_server.py b/tests/test/test_mcp_server.py similarity index 100% rename from test/test_mcp_server.py rename to tests/test/test_mcp_server.py diff --git a/test/test_message_text_index_population.py b/tests/test/test_message_text_index_population.py similarity index 100% rename from test/test_message_text_index_population.py rename to tests/test/test_message_text_index_population.py diff --git a/test/test_message_text_index_serialization.py b/tests/test/test_message_text_index_serialization.py similarity index 100% rename from test/test_message_text_index_serialization.py rename to tests/test/test_message_text_index_serialization.py diff --git a/test/test_messageindex.py b/tests/test/test_messageindex.py similarity index 100% rename from test/test_messageindex.py rename to tests/test/test_messageindex.py diff --git a/test/test_online.py b/tests/test/test_online.py similarity index 100% rename from test/test_online.py rename to tests/test/test_online.py diff --git a/test/test_podcast_incremental.py b/tests/test/test_podcast_incremental.py similarity index 100% rename from test/test_podcast_incremental.py rename to tests/test/test_podcast_incremental.py diff --git a/test/test_podcasts.py b/tests/test/test_podcasts.py similarity index 95% rename from test/test_podcasts.py rename to tests/test/test_podcasts.py index 7113a803..2ac9b3a1 100644 --- a/test/test_podcasts.py +++ b/tests/test/test_podcasts.py @@ -13,6 +13,10 @@ from typeagent.podcasts import podcast_ingest from typeagent.podcasts.podcast import Podcast +tests_dir = os.path.dirname(__file__) +root_dir = os.path.dirname(tests_dir) +DEFAULT_FILE = os.path.join(root_dir, "testdata", "FakePodcast.txt") + @pytest.mark.asyncio async def test_ingest_podcast( @@ -21,7 +25,7 @@ async def test_ingest_podcast( # Import the podcast settings = ConversationSettings(embedding_model) pod = await podcast_ingest.ingest_podcast( - "testdata/FakePodcast.txt", + DEFAULT_FILE, settings, None, Datetime.now(timezone.utc), # Use timezone-aware datetime diff --git a/test/test_property_index_population.py b/tests/test/test_property_index_population.py similarity index 100% rename from test/test_property_index_population.py rename to tests/test/test_property_index_population.py diff --git a/test/test_propindex.py b/tests/test/test_propindex.py similarity index 100% rename from test/test_propindex.py rename to tests/test/test_propindex.py diff --git a/test/test_query.py b/tests/test/test_query.py similarity index 100% rename from test/test_query.py rename to tests/test/test_query.py diff --git a/test/test_query_method.py b/tests/test/test_query_method.py similarity index 100% rename from test/test_query_method.py rename to tests/test/test_query_method.py diff --git a/test/test_related_terms_fast.py b/tests/test/test_related_terms_fast.py similarity index 100% rename from test/test_related_terms_fast.py rename to tests/test/test_related_terms_fast.py diff --git a/test/test_related_terms_index_population.py b/tests/test/test_related_terms_index_population.py similarity index 100% rename from test/test_related_terms_index_population.py rename to tests/test/test_related_terms_index_population.py diff --git a/test/test_reltermsindex.py b/tests/test/test_reltermsindex.py similarity index 100% rename from test/test_reltermsindex.py rename to tests/test/test_reltermsindex.py diff --git a/test/test_searchlib.py b/tests/test/test_searchlib.py similarity index 100% rename from test/test_searchlib.py rename to tests/test/test_searchlib.py diff --git a/test/test_secindex.py b/tests/test/test_secindex.py similarity index 100% rename from test/test_secindex.py rename to tests/test/test_secindex.py diff --git a/test/test_secindex_storage_integration.py b/tests/test/test_secindex_storage_integration.py similarity index 100% rename from test/test_secindex_storage_integration.py rename to tests/test/test_secindex_storage_integration.py diff --git a/test/test_semrefindex.py b/tests/test/test_semrefindex.py similarity index 100% rename from test/test_semrefindex.py rename to tests/test/test_semrefindex.py diff --git a/test/test_serialization.py b/tests/test/test_serialization.py similarity index 100% rename from test/test_serialization.py rename to tests/test/test_serialization.py diff --git a/test/test_sqlite_indexes.py b/tests/test/test_sqlite_indexes.py similarity index 100% rename from test/test_sqlite_indexes.py rename to tests/test/test_sqlite_indexes.py diff --git a/test/test_sqlitestore.py b/tests/test/test_sqlitestore.py similarity index 100% rename from test/test_sqlitestore.py rename to tests/test/test_sqlitestore.py diff --git a/test/test_storage_providers_unified.py b/tests/test/test_storage_providers_unified.py similarity index 100% rename from test/test_storage_providers_unified.py rename to tests/test/test_storage_providers_unified.py diff --git a/test/test_timestampindex.py b/tests/test/test_timestampindex.py similarity index 100% rename from test/test_timestampindex.py rename to tests/test/test_timestampindex.py diff --git a/test/test_transcripts.py b/tests/test/test_transcripts.py similarity index 100% rename from test/test_transcripts.py rename to tests/test/test_transcripts.py diff --git a/test/test_utils.py b/tests/test/test_utils.py similarity index 100% rename from test/test_utils.py rename to tests/test/test_utils.py diff --git a/test/test_vectorbase.py b/tests/test/test_vectorbase.py similarity index 100% rename from test/test_vectorbase.py rename to tests/test/test_vectorbase.py diff --git a/testdata/Confuse-A-Cat.vtt b/tests/testdata/Confuse-A-Cat.vtt similarity index 100% rename from testdata/Confuse-A-Cat.vtt rename to tests/testdata/Confuse-A-Cat.vtt diff --git a/testdata/Episode_53_AdrianTchaikovsky.txt b/tests/testdata/Episode_53_AdrianTchaikovsky.txt similarity index 100% rename from testdata/Episode_53_AdrianTchaikovsky.txt rename to tests/testdata/Episode_53_AdrianTchaikovsky.txt diff --git a/testdata/Episode_53_AdrianTchaikovsky_index_data.json b/tests/testdata/Episode_53_AdrianTchaikovsky_index_data.json similarity index 100% rename from testdata/Episode_53_AdrianTchaikovsky_index_data.json rename to tests/testdata/Episode_53_AdrianTchaikovsky_index_data.json diff --git a/testdata/Episode_53_AdrianTchaikovsky_index_embeddings.bin b/tests/testdata/Episode_53_AdrianTchaikovsky_index_embeddings.bin similarity index 100% rename from testdata/Episode_53_AdrianTchaikovsky_index_embeddings.bin rename to tests/testdata/Episode_53_AdrianTchaikovsky_index_embeddings.bin diff --git a/testdata/FakePodcast.txt b/tests/testdata/FakePodcast.txt similarity index 100% rename from testdata/FakePodcast.txt rename to tests/testdata/FakePodcast.txt diff --git a/testdata/Parrot_Sketch.vtt b/tests/testdata/Parrot_Sketch.vtt similarity index 100% rename from testdata/Parrot_Sketch.vtt rename to tests/testdata/Parrot_Sketch.vtt diff --git a/testdata/PythonDocumentary.vtt b/tests/testdata/PythonDocumentary.vtt similarity index 100% rename from testdata/PythonDocumentary.vtt rename to tests/testdata/PythonDocumentary.vtt diff --git a/testdata/Short.vtt b/tests/testdata/Short.vtt similarity index 100% rename from testdata/Short.vtt rename to tests/testdata/Short.vtt