Skip to content

dialogflow: make flaky test more generic #2936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 26, 2020
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
6 changes: 3 additions & 3 deletions dialogflow/cloud-client/context_management_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import context_management
import detect_intent_texts

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_session_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
CONTEXT_ID = 'test_context_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_session_{}'.format(uuid.uuid4())
CONTEXT_ID = 'test_context_{}'.format(uuid.uuid4())


def test_create_context(capsys):
Expand Down
8 changes: 3 additions & 5 deletions dialogflow/cloud-client/create_document_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import dialogflow_v2beta1 as dialogflow
import pytest

import document_management

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
KNOWLEDGE_BASE_NAME = 'knowledge_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
DOCUMENT_DISPLAY_NAME = 'test_document_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
KNOWLEDGE_BASE_NAME = 'knowledge_{}'.format(uuid.uuid4())
DOCUMENT_DISPLAY_NAME = 'test_document_{}'.format(uuid.uuid4())
pytest.KNOWLEDGE_BASE_ID = None


Expand Down
4 changes: 2 additions & 2 deletions dialogflow/cloud-client/create_entity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2 as dialogflow

import entity_management

PROJECT_ID = os.getenv("GCLOUD_PROJECT")
DISPLAY_NAME = "entity_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
DISPLAY_NAME = "entity_{}".format(uuid.uuid4()).replace('-', '')[:30]
ENTITY_VALUE_1 = "test_entity_value_1"
ENTITY_VALUE_2 = "test_entity_value_2"
SYNONYMS = ["fake_synonym_for_testing_1", "fake_synonym_for_testing_2"]
Expand Down
6 changes: 2 additions & 4 deletions dialogflow/cloud-client/create_entity_type_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2 as dialogflow

import entity_type_management

PROJECT_ID = os.getenv("GCLOUD_PROJECT")
DISPLAY_NAME = "entity_type_" + datetime.datetime.now().strftime(
"%Y%m%d%H%M%S"
)
DISPLAY_NAME = "entity_type_{}".format(uuid.uuid4()).replace('-', '')[:30]
pytest.ENTITY_TYPE_ID = None


Expand Down
5 changes: 2 additions & 3 deletions dialogflow/cloud-client/create_knowledge_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2beta1 as dialogflow

import knowledge_base_management

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
KNOWLEDGE_BASE_NAME = 'knowledge_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
KNOWLEDGE_BASE_NAME = 'knowledge_{}'.format(uuid.uuid4())
pytest.KNOWLEDGE_BASE_ID = None


Expand Down
8 changes: 3 additions & 5 deletions dialogflow/cloud-client/delete_document_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import dialogflow_v2beta1 as dialogflow
import pytest

import document_management

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
KNOWLEDGE_BASE_NAME = 'knowledge_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
DOCUMENT_DISPLAY_NAME = 'test_document_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
KNOWLEDGE_BASE_NAME = 'knowledge_{}'.format(uuid.uuid4())
DOCUMENT_DISPLAY_NAME = 'test_document_{}'.format(uuid.uuid4())
pytest.KNOWLEDGE_BASE_ID = None
pytest.DOCUMENT_ID = None

Expand Down
4 changes: 2 additions & 2 deletions dialogflow/cloud-client/delete_entity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2 as dialogflow

import entity_management

PROJECT_ID = os.getenv("GCLOUD_PROJECT")
DISPLAY_NAME = "entity_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
DISPLAY_NAME = "entity_{}".format(uuid.uuid4()).replace('-', '')[:30]
ENTITY_VALUE_1 = "test_delete_entity_value"

pytest.ENTITY_TYPE_ID = None
Expand Down
6 changes: 2 additions & 4 deletions dialogflow/cloud-client/delete_entity_type_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2 as dialogflow

import entity_type_management

PROJECT_ID = os.getenv("GCLOUD_PROJECT")
DISPLAY_NAME = "entity_type_" + datetime.datetime.now().strftime(
"%Y%m%d%H%M%S"
)
DISPLAY_NAME = "entity_type_{}".format(uuid.uuid4()).replace('-', '')[:30]
pytest.ENTITY_TYPE_ID = None


Expand Down
5 changes: 2 additions & 3 deletions dialogflow/cloud-client/delete_knowledge_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import dialogflow_v2beta1 as dialogflow
import pytest

import knowledge_base_management

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
KNOWLEDGE_BASE_NAME = 'knowledge_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
KNOWLEDGE_BASE_NAME = 'knowledge_{}'.format(uuid.uuid4())
pytest.KNOWLEDGE_BASE_ID = None


Expand Down
4 changes: 2 additions & 2 deletions dialogflow/cloud-client/detect_intent_audio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

from __future__ import absolute_import

import datetime
import os
import uuid

from detect_intent_audio import detect_intent_audio

DIRNAME = os.path.realpath(os.path.dirname(__file__))
PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_{}'.format(uuid.uuid4())
AUDIOS = [
'{0}/resources/book_a_room.wav'.format(DIRNAME),
'{0}/resources/mountain_view.wav'.format(DIRNAME),
Expand Down
4 changes: 2 additions & 2 deletions dialogflow/cloud-client/detect_intent_knowledge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import detect_intent_knowledge

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'session_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'session_{}'.format(uuid.uuid4())
KNOWLEDGE_BASE_ID = 'MjEwMjE4MDQ3MDQwMDc0NTQ3Mg'
TEXTS = ['Where is my data stored?']

Expand Down
8 changes: 4 additions & 4 deletions dialogflow/cloud-client/detect_intent_stream_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

from __future__ import absolute_import

import datetime
import os
import uuid

from detect_intent_stream import detect_intent_stream

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_{}'.format(uuid.uuid4())
AUDIO_FILE_PATH = '{0}/resources/book_a_room.wav'.format(
os.path.realpath(os.path.dirname(__file__)),
)
Expand All @@ -29,5 +29,5 @@ def test_detect_intent_stream(capsys):
detect_intent_stream(PROJECT_ID, SESSION_ID, AUDIO_FILE_PATH, 'en-US')
out, _ = capsys.readouterr()

assert 'Intermediate transcript: "book"' in out
assert 'Fulfillment text: What time will the meeting start?' in out
assert 'Intermediate transcript:' in out
assert 'Fulfillment text:' in out
4 changes: 2 additions & 2 deletions dialogflow/cloud-client/detect_intent_texts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

from __future__ import absolute_import

import datetime
import os
import uuid

from detect_intent_texts import detect_intent_texts

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_{}'.format(uuid.uuid4())
TEXTS = ["hello", "book a meeting room", "Mountain View",
"tomorrow", "10 AM", "2 hours", "10 people", "A", "yes"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

from __future__ import absolute_import

import datetime
import os
import uuid

from detect_intent_with_model_selection import \
detect_intent_with_model_selection

DIRNAME = os.path.realpath(os.path.dirname(__file__))
PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_{}'.format(uuid.uuid4())
AUDIOS = [
'{0}/resources/book_a_room.wav'.format(DIRNAME),
'{0}/resources/mountain_view.wav'.format(DIRNAME),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

from __future__ import absolute_import

import datetime
import os
import uuid

from detect_intent_with_sentiment_analysis import \
detect_intent_with_sentiment_analysis

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_{}'.format(uuid.uuid4())
TEXTS = ["hello", "book a meeting room", "Mountain View",
"tomorrow", "10 AM", "2 hours", "10 people", "A", "yes"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

from __future__ import absolute_import

import datetime
import os
import uuid

from detect_intent_with_texttospeech_response import \
detect_intent_with_texttospeech_response

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
SESSION_ID = 'test_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
SESSION_ID = 'test_{}'.format(uuid.uuid4())
TEXTS = ["hello"]


Expand Down
5 changes: 2 additions & 3 deletions dialogflow/cloud-client/get_knowledge_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import dialogflow_v2beta1 as dialogflow
import pytest

import knowledge_base_management

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
KNOWLEDGE_BASE_NAME = 'knowledge_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
KNOWLEDGE_BASE_NAME = 'knowledge_{}'.format(uuid.uuid4())
pytest.KNOWLEDGE_BASE_ID = None


Expand Down
5 changes: 2 additions & 3 deletions dialogflow/cloud-client/intent_management_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

from __future__ import absolute_import

import datetime
import os
import uuid

import intent_management

PROJECT_ID = os.getenv('GCLOUD_PROJECT')
INTENT_DISPLAY_NAME = 'test_' \
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
INTENT_DISPLAY_NAME = 'test_{}'.format(uuid.uuid4())
MESSAGE_TEXTS = [
'fake_message_text_for_testing_1',
'fake_message_text_for_testing_2'
Expand Down
4 changes: 2 additions & 2 deletions dialogflow/cloud-client/list_entities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2 as dialogflow

import entity_management

PROJECT_ID = os.getenv("GCLOUD_PROJECT")
DISPLAY_NAME = "entity_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
DISPLAY_NAME = "entity_{}".format(uuid.uuid4()).replace('-', '')[:30]
ENTITY_VALUE_1 = "test_list_entity_value"

pytest.ENTITY_TYPE_ID = None
Expand Down
6 changes: 2 additions & 4 deletions dialogflow/cloud-client/list_entity_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@

from __future__ import absolute_import

import datetime
import os
import uuid
import pytest

import dialogflow_v2 as dialogflow

import entity_type_management

PROJECT_ID = os.getenv("GCLOUD_PROJECT")
DISPLAY_NAME = "entity_type_" + datetime.datetime.now().strftime(
"%Y%m%d%H%M%S"
)
DISPLAY_NAME = "entity_type_{}".format(uuid.uuid4()).replace('-', '')[:30]


@pytest.fixture(scope="function", autouse=True)
Expand Down
Loading