def test_already_exists(self, create_product_set_mock, get_conn): get_conn.return_value = {} create_product_set_mock.side_effect = AlreadyExists(message='') # Exception AlreadyExists not raised, caught in the operator's execute() - idempotence op = CloudVisionProductSetCreateOperator( location=LOCATION_TEST, product_set=PRODUCTSET_TEST, product_set_id=PRODUCTSET_ID_TEST, project_id='mock-project-id', task_id='id', ) result = op.execute(None) self.assertEqual(PRODUCTSET_ID_TEST, result)
def test_already_exists(self, create_product_set_mock, get_conn): get_conn.return_value = {} create_product_set_mock.side_effect = AlreadyExists(message='') # Exception AlreadyExists not raised, caught in the operator's execute() - idempotence op = CloudVisionProductSetCreateOperator( location=LOCATION_TEST, product_set=PRODUCTSET_TEST, product_set_id=PRODUCTSET_ID_TEST, project_id='mock-project-id', task_id='id', ) result = op.execute(None) self.assertEqual(PRODUCTSET_ID_TEST, result)
def test_minimal_green_path(self, mock_hook): mock_hook.return_value.create_product_set.return_value = {} op = CloudVisionProductSetCreateOperator(location=LOCATION_TEST, product_set=PRODUCTSET_TEST, task_id='id') op.execute(context=None) mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID) mock_hook.return_value.create_product_set.assert_called_once_with( location=LOCATION_TEST, product_set=PRODUCTSET_TEST, product_set_id=None, project_id=None, retry=None, timeout=None, metadata=None, )
def test_minimal_green_path(self, mock_hook): mock_hook.return_value.create_product_set.return_value = {} op = CloudVisionProductSetCreateOperator( location=LOCATION_TEST, product_set=PRODUCTSET_TEST, task_id='id' ) op.execute(context=None) mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID) mock_hook.return_value.create_product_set.assert_called_once_with( location=LOCATION_TEST, product_set=PRODUCTSET_TEST, product_set_id=None, project_id=None, retry=None, timeout=None, metadata=None, )
# [START howto_operator_vision_detect_image_param] DETECT_IMAGE = {"source": {"image_uri": GCP_VISION_ANNOTATE_IMAGE_URL}} # [END howto_operator_vision_detect_image_param] with models.DAG('example_gcp_vision_autogenerated_id', default_args=default_args, schedule_interval=None) as dag_autogenerated_id: # ################################## # # ### Autogenerated IDs examples ### # # ################################## # # [START howto_operator_vision_product_set_create] product_set_create = CloudVisionProductSetCreateOperator( location=GCP_VISION_LOCATION, product_set=product_set, retry=Retry(maximum=10.0), timeout=5, task_id='product_set_create', ) # [END howto_operator_vision_product_set_create] # [START howto_operator_vision_product_set_get] product_set_get = CloudVisionProductSetGetOperator( location=GCP_VISION_LOCATION, product_set_id="{{ task_instance.xcom_pull('product_set_create') }}", task_id='product_set_get', ) # [END howto_operator_vision_product_set_get] # [START howto_operator_vision_product_set_update] product_set_update = CloudVisionProductSetUpdateOperator(