Skip to content

Commit

Permalink
Enable integration tests to run in the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
abhahn committed Jun 28, 2024
1 parent ff30796 commit e3ec9fb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 57 deletions.
26 changes: 25 additions & 1 deletion tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def secret_client() -> SecretClient:


@pytest.fixture(scope="module")
def dotenv_template_params(secret_client: SecretClient) -> dict[str, str]:
def dotenv_template_params_from_kv(secret_client: SecretClient) -> dict[str, str]:
secrets_properties_list = secret_client.list_properties_of_secrets()
secrets = {}
for secret in secrets_properties_list:
Expand All @@ -26,3 +26,27 @@ def dotenv_template_params(secret_client: SecretClient) -> dict[str, str]:
return secrets


@pytest.fixture(scope="module")
def dotenv_template_params_from_env() -> dict[str, str]:
env_secrets = [
"azureCosmosdbAccount",
"azureCosmosdbAccountKey",
"azureCosmosdbConversationsContainer",
"azureCosmosdbDatabase",
"azureOpenaiEmbeddingName"
"azureOpenaiEndpoint",
"azureOpenaiModel",
"azureOpenaiKey",
"azureSearchIndex",
"azureSearchKey",
"azureSearchQuery",
"azureSearchService",
"elasticsearchEmbeddingModelId",
"elasticsearchEncodedApiKey",
"elasticsearchEndpoint",
"elasticsearchIndex",
"elasticsearchQuery"
]

return {s: os.getenv(s.upper()) for s in env_secrets}

32 changes: 16 additions & 16 deletions tests/integration_tests/test_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def use_elasticsearch_embeddings(request):
@pytest.fixture(scope="function")
def dotenv_rendered_template_path(
request,
dotenv_template_params,
dotenv_template_params_from_env,
datasource,
enable_chat_history,
stream,
Expand All @@ -83,30 +83,30 @@ def dotenv_rendered_template_path(
)

if datasource != "none":
dotenv_template_params["datasourceType"] = datasource
dotenv_template_params_from_env["datasourceType"] = datasource

if datasource != "Elasticsearch" and use_elasticsearch_embeddings:
pytest.skip("Elasticsearch embeddings not supported for test.")

if datasource == "Elasticsearch":
dotenv_template_params["useElasticsearchEmbeddings"] = use_elasticsearch_embeddings
dotenv_template_params_from_env["useElasticsearchEmbeddings"] = use_elasticsearch_embeddings

dotenv_template_params["useAoaiEmbeddings"] = use_aoai_embeddings
dotenv_template_params_from_env["useAoaiEmbeddings"] = use_aoai_embeddings

if use_aoai_embeddings or use_elasticsearch_embeddings:
dotenv_template_params["azureSearchQueryType"] = "vector"
dotenv_template_params["elasticsearchQueryType"] = "vector"
dotenv_template_params_from_env["azureSearchQueryType"] = "vector"
dotenv_template_params_from_env["elasticsearchQueryType"] = "vector"
else:
dotenv_template_params["azureSearchQueryType"] = "simple"
dotenv_template_params["elasticsearchQueryType"] = "simple"
dotenv_template_params_from_env["azureSearchQueryType"] = "simple"
dotenv_template_params_from_env["elasticsearchQueryType"] = "simple"

dotenv_template_params["enableChatHistory"] = enable_chat_history
dotenv_template_params["azureOpenaiStream"] = stream
dotenv_template_params_from_env["enableChatHistory"] = enable_chat_history
dotenv_template_params_from_env["azureOpenaiStream"] = stream

return render_template_to_tempfile(
rendered_template_name,
template_path,
**dotenv_template_params
**dotenv_template_params_from_env
)


Expand All @@ -121,12 +121,12 @@ def test_app(dotenv_rendered_template_path) -> Quart:


@pytest.mark.asyncio
async def test_dotenv(test_app: Quart, dotenv_template_params: dict[str, str]):
if dotenv_template_params["datasourceType"] == "AzureCognitiveSearch":
message_content = dotenv_template_params["azureSearchQuery"]
async def test_dotenv(test_app: Quart, dotenv_template_params_from_env: dict[str, str]):
if dotenv_template_params_from_env["datasourceType"] == "AzureCognitiveSearch":
message_content = dotenv_template_params_from_env["azureSearchQuery"]

elif dotenv_template_params["datasourceType"] == "Elasticsearch":
message_content = dotenv_template_params["elasticsearchQuery"]
elif dotenv_template_params_from_env["datasourceType"] == "Elasticsearch":
message_content = dotenv_template_params_from_env["elasticsearchQuery"]

else:
message_content = "What is Contoso?"
Expand Down
40 changes: 0 additions & 40 deletions tests/integration_tests/test_startup_scripts.py

This file was deleted.

0 comments on commit e3ec9fb

Please sign in to comment.