def test_minimal_green_path(self, mock_hook):
     op = CloudVisionReferenceImageCreateOperator(
         location=LOCATION_TEST,
         product_id=PRODUCT_ID_TEST,
         reference_image=REFERENCE_IMAGE_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_reference_image.assert_called_once_with(
         location=LOCATION_TEST,
         product_id=PRODUCT_ID_TEST,
         reference_image=REFERENCE_IMAGE_TEST,
         reference_image_id=None,
         project_id=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Beispiel #2
0
 def test_already_exists(self, mock_hook):
     # Exception AlreadyExists not raised, caught in the operator's execute() - idempotence
     op = CloudVisionReferenceImageCreateOperator(
         location=LOCATION_TEST,
         product_id=PRODUCT_ID_TEST,
         reference_image=REFERENCE_IMAGE_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_reference_image.assert_called_once_with(
         location=LOCATION_TEST,
         product_id=PRODUCT_ID_TEST,
         reference_image=REFERENCE_IMAGE_TEST,
         reference_image_id=None,
         project_id=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Beispiel #3
0
    # [END howto_operator_vision_product_update]

    # [START howto_operator_vision_product_delete]
    product_delete = CloudVisionProductDeleteOperator(
        location=GCP_VISION_LOCATION,
        product_id="{{ task_instance.xcom_pull('product_create') }}",
        task_id='product_delete',
    )
    # [END howto_operator_vision_product_delete]

    # [START howto_operator_vision_reference_image_create]
    reference_image_create = CloudVisionReferenceImageCreateOperator(
        location=GCP_VISION_LOCATION,
        reference_image=reference_image,
        product_id="{{ task_instance.xcom_pull('product_create') }}",
        reference_image_id=GCP_VISION_REFERENCE_IMAGE_ID,
        retry=Retry(maximum=10.0),
        timeout=5,
        task_id='reference_image_create',
    )
    # [END howto_operator_vision_reference_image_create]

    # [START howto_operator_vision_add_product_to_product_set]
    add_product_to_product_set = CloudVisionAddProductToProductSetOperator(
        location=GCP_VISION_LOCATION,
        product_set_id="{{ task_instance.xcom_pull('product_set_create') }}",
        product_id="{{ task_instance.xcom_pull('product_create') }}",
        retry=Retry(maximum=10.0),
        timeout=5,
        task_id='add_product_to_product_set',
    )