Skip to content

Commit 6d238d4

Browse files
authored
fix: change dialogflow intent display name (GoogleCloudPlatform#9174)
The main change in this PR is making the `display_name` unique (line 36). This test was failing because there is an existing intent with "fake_intent" in the test project. Now it adds a UUID to the end of the display name. Typing was also added to the test file along with this fix. Fixes GoogleCloudPlatform#9154
1 parent 0f307be commit 6d238d4

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

‎dialogflow/update_intent_test.py‎

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,44 @@
2222

2323
from update_intent import update_intent
2424

25-
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
25+
PROJECT_ID: str = os.getenv("GOOGLE_CLOUD_PROJECT")
2626
pytest.INTENT_ID = None
2727

2828

29-
def create_intent(project_id):
30-
intents_client = IntentsClient()
29+
def create_intent(project_id: str) -> str:
30+
intents_client: IntentsClient = IntentsClient()
3131

32-
parent = AgentsClient.agent_path(project_id)
32+
parent: str = AgentsClient.agent_path(project_id)
3333

34-
intent = Intent()
34+
intent: Intent = Intent()
3535

36-
intent.display_name = "fake_intent"
36+
intent.display_name = f"fake_intent_{uuid.uuid4()}"
3737

38-
intents = intents_client.create_intent(request={"parent": parent, "intent": intent})
38+
intents: Intent = intents_client.create_intent(
39+
request={"parent": parent, "intent": intent}
40+
)
3941

4042
return intents.name.split("/")[4]
4143

4244

4345
@pytest.fixture(scope="function", autouse=True)
44-
def setup_teardown():
46+
def setup_teardown() -> None:
4547
pytest.INTENT_ID = create_intent(project_id=PROJECT_ID)
4648
print("Created Intent in setUp")
4749

4850

49-
def test_update_intent():
51+
def test_update_intent() -> None:
5052

51-
fake_intent = "fake_intent_{}".format(uuid.uuid4())
53+
# A new display name with an updated suffix
54+
new_display_name: str = f"fake_intent_{uuid.uuid4()}"
5255

53-
actualResponse = update_intent(PROJECT_ID, pytest.INTENT_ID, fake_intent)
54-
expectedResponse = fake_intent
56+
actual_response: Intent = update_intent(
57+
PROJECT_ID, pytest.INTENT_ID, new_display_name
58+
)
59+
expected_response: str = new_display_name
5560

56-
intents_client = IntentsClient()
61+
intents_client: IntentsClient = IntentsClient()
5762

58-
intents_client.delete_intent(name=actualResponse.name)
63+
intents_client.delete_intent(name=actual_response.name)
5964

60-
assert actualResponse.display_name == expectedResponse
65+
assert actual_response.display_name == expected_response

0 commit comments

Comments
 (0)