|
| 1 | +# Copyright 2020, Google LLC |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# |
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +# |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | + |
| 14 | +"""Test for create_agent""" |
| 15 | + |
| 16 | +from datetime import date |
| 17 | +import os |
| 18 | + |
| 19 | +from google.cloud.dialogflowcx_v3.services.agents.client import AgentsClient |
| 20 | +from google.cloud.dialogflowcx_v3.types.agent import DeleteAgentRequest |
| 21 | + |
| 22 | +import pytest |
| 23 | + |
| 24 | +from create_agent import create_agent |
| 25 | + |
| 26 | +PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") |
| 27 | +pytest.AGENT_PATH = "" |
| 28 | + |
| 29 | + |
| 30 | +def delete_agent(name): |
| 31 | + agents_client = AgentsClient() |
| 32 | + request = DeleteAgentRequest(name=name) |
| 33 | + agents_client.delete_agent(request=request) |
| 34 | + |
| 35 | + |
| 36 | +def test_create_agent(): |
| 37 | + today = date.today() |
| 38 | + agentName = "tempAgent." + today.strftime("%d.%m.%Y") |
| 39 | + response = create_agent(PROJECT_ID, agentName) |
| 40 | + delete_agent(response.name) |
| 41 | + |
| 42 | + assert response.display_name == agentName |
0 commit comments