potiuk commented on code in PR #74125:
URL: https://github.com/apache/airflow/pull/74125#discussion_r4186411134


##########
providers/amazon/tests/system/amazon/aws/example_comprehend_document_classifier.py:
##########
@@ -114,13 +114,28 @@ def document_classifier_workflow():
     # [END howto_sensor_create_document_classifier]
 
     @task(trigger_rule=TriggerRule.ALL_DONE)
-    def delete_classifier(document_classifier_arn: str):
-        
ComprehendHook().conn.delete_document_classifier(DocumentClassifierArn=document_classifier_arn)
+    def delete_classifier():

Review Comment:
   `classifier_name` here is the module-level f-string built from the `ENV_ID` 
XComArg. Nothing renders it inside this `@task` body, so the filter gets the 
literal `{{ task_instance.xcom_pull(...) }}-custom-document-classifier` string 
and matches nothing. The classifier is never deleted. Passing it in as an 
argument makes Airflow render it (`op_args` is templated):
   ```suggestion
       def delete_classifier(classifier_name: str):
   ```
   and on line 138: `delete_classifier(classifier_name),`



##########
providers/amazon/tests/unit/amazon/aws/waiters/test_comprehend.py:
##########
@@ -102,3 +103,38 @@ def test_create_document_classifier_wait(self, 
mock_describe_document_classifier
         ComprehendHook().get_waiter(self.WAITER_NAME).wait(
             DocumentClassifierArn="arn", WaiterConfig={"Delay": 0.01, 
"MaxAttempts": 3}
         )
+
+
+class 
TestComprehendDocumentClassifierDeletableWaiter(TestComprehendCustomWaitersBase):
+    WAITER_NAME = "document_classifier_deletable"
+
+    @pytest.fixture
+    def mock_describe_document_classifier(self):
+        with mock.patch.object(self.client, "describe_document_classifier") as 
mock_getter:
+            yield mock_getter
+
+    @pytest.mark.parametrize("state", ["TRAINED", "TRAINED_WITH_WARNING", 
"IN_ERROR", "STOPPED"])
+    def test_document_classifier_deletable(self, state, 
mock_describe_document_classifier):
+        mock_describe_document_classifier.return_value = 
{"DocumentClassifierProperties": {"Status": state}}
+
+        
ComprehendHook().get_waiter(self.WAITER_NAME).wait(DocumentClassifierArn="arn")

Review Comment:
   Following up on Sameer's suggestion, it's worth asserting the waiter calls 
the right API with the ARN:
   ```suggestion
           
ComprehendHook().get_waiter(self.WAITER_NAME).wait(DocumentClassifierArn="arn")
   
           
mock_describe_document_classifier.assert_called_once_with(DocumentClassifierArn="arn")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to