diff --git a/integtests/chatbot-api/kendra_workspace_test.py b/integtests/chatbot-api/kendra_workspace_test.py index 38af32ff5..79ed17f0b 100644 --- a/integtests/chatbot-api/kendra_workspace_test.py +++ b/integtests/chatbot-api/kendra_workspace_test.py @@ -47,6 +47,7 @@ def test_create(client: AppSyncClient, default_embed_model): break assert ready == True + def test_add_file(client: AppSyncClient): if pytest.skip_flag == True: pytest.skip("Kendra is not enabled.") @@ -60,12 +61,16 @@ def test_add_file(client: AppSyncClient): s3_client = boto3.client("s3") fields = result.get("fields") - #"fields" string format: - #{key=544aeaa9-3f3d-4995-843d-e66a993bf5e8/context.txt, AWSAccessKeyId=XXX, x-amz-security-token=YYY + # "fields" string format: + # {key=544aeaa9-3f3d-4995-843d-e66a993bf5e8/context.txt, AWSAccessKeyId=XXX pairs = [pair.strip() for pair in fields.replace("{", "").split(',')] fields_dict = dict(pair.split('=', 1) for pair in pairs) bucket_name = result.get("url").split("//")[1].split(".")[0] - s3_client.put_object(Body=b"The Integ Test flower is yellow.", Bucket=bucket_name, Key=fields_dict.get("key")) + s3_client.put_object( + Body=b"The Integ Test flower is yellow.", + Bucket=bucket_name, + Key=fields_dict.get("key") + ) client.start_kendra_data_sync(pytest.workspace.get("id")) @@ -73,7 +78,8 @@ def test_add_file(client: AppSyncClient): syncRetries = 0 while syncInProgress and syncRetries < 50: time.sleep(10) - syncInProgress = client.is_kendra_data_synching(pytest.workspace.get("id")).get("isKendraDataSynching") + syncStatus = client.is_kendra_data_synching(pytest.workspace.get("id")) + syncInProgress = syncStatus.get("isKendraDataSynching") syncRetries += 1 assert syncInProgress == False @@ -87,6 +93,7 @@ def test_add_file(client: AppSyncClient): assert pytest.document.get("status") == "processed" assert pytest.document.get("workspaceId") == pytest.workspace.get("id") + def test_semantic_search(client: AppSyncClient): if pytest.skip_flag == True: pytest.skip("Kendra is not enabled.") @@ -105,7 +112,8 @@ def test_semantic_search(client: AppSyncClient): if len(result.get("items")) == 1: ready = True assert result.get("engine") == "kendra" - assert result.get("items")[0].get("content") == "The Integ Test flower is yellow." + fileContent = result.get("items")[0].get("content") + assert fileContent == "The Integ Test flower is yellow." assert ready == True @@ -144,6 +152,7 @@ def test_query_llm(client, default_model, default_provider): client.delete_session(session_id) assert found == True + def test_delete_document(client: AppSyncClient): if pytest.skip_flag == True: pytest.skip("Kendra is not enabled.") @@ -171,6 +180,7 @@ def test_delete_document(client: AppSyncClient): break assert ready == True + def test_delete_workspace(client: AppSyncClient): if pytest.skip_flag == True: pytest.skip("Kendra is not enabled.") diff --git a/integtests/clients/appsync_client.py b/integtests/clients/appsync_client.py index ac83b555d..8e118d6ea 100644 --- a/integtests/clients/appsync_client.py +++ b/integtests/clients/appsync_client.py @@ -276,10 +276,10 @@ def list_kendra_indexes(self): query = dsl_gql( DSLQuery( self.schema.Query.listKendraIndexes.select( - self.schema.KendraIndex.id, - self.schema.KendraIndex.name, - self.schema.KendraIndex.external, + self.schema.KendraIndex.id, + self.schema.KendraIndex.name, + self.schema.KendraIndex.external, ) ) ) - return self.client.execute(query).get("listKendraIndexes") \ No newline at end of file + return self.client.execute(query).get("listKendraIndexes")