|
| 1 | +# Copyright 2022 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import create_execution_with_sdk_sample |
| 16 | + |
| 17 | +from google.cloud.aiplatform.compat.types import execution as gca_execution |
| 18 | + |
| 19 | +import test_constants as constants |
| 20 | + |
| 21 | + |
| 22 | +def test_create_execution_sample( |
| 23 | + mock_sdk_init, mock_create_artifact, mock_create_execution, mock_execution, |
| 24 | +): |
| 25 | + |
| 26 | + input_art = mock_create_artifact() |
| 27 | + output_art = mock_create_artifact() |
| 28 | + |
| 29 | + exc = create_execution_with_sdk_sample.create_execution_sample( |
| 30 | + display_name=constants.DISPLAY_NAME, |
| 31 | + input_artifacts=[input_art], |
| 32 | + output_artifacts=[output_art], |
| 33 | + project=constants.PROJECT, |
| 34 | + location=constants.LOCATION, |
| 35 | + execution_id=constants.RESOURCE_ID, |
| 36 | + metadata=constants.METADATA, |
| 37 | + schema_version=constants.SCHEMA_VERSION, |
| 38 | + description=constants.DESCRIPTION, |
| 39 | + ) |
| 40 | + |
| 41 | + mock_sdk_init.assert_called_with( |
| 42 | + project=constants.PROJECT, location=constants.LOCATION, |
| 43 | + ) |
| 44 | + |
| 45 | + mock_create_execution.assert_called_with( |
| 46 | + state=gca_execution.Execution.State.RUNNING, |
| 47 | + schema_title="system.ContainerExecution", |
| 48 | + resource_id=constants.RESOURCE_ID, |
| 49 | + display_name=constants.DISPLAY_NAME, |
| 50 | + schema_version=constants.SCHEMA_VERSION, |
| 51 | + metadata=constants.METADATA, |
| 52 | + description=constants.DESCRIPTION, |
| 53 | + metadata_store_id="default", |
| 54 | + project=None, |
| 55 | + location=None, |
| 56 | + credentials=None, |
| 57 | + ) |
| 58 | + |
| 59 | + mock_execution.assign_input_artifacts.assert_called_with([input_art]) |
| 60 | + mock_execution.assign_output_artifacts.assert_called_with([output_art]) |
| 61 | + |
| 62 | + assert exc is mock_execution |
0 commit comments