o-nikolas commented on code in PR #46096:
URL: https://github.com/apache/airflow/pull/46096#discussion_r1932866160
##########
providers/tests/amazon/aws/transfers/test_http_to_s3.py:
##########
@@ -60,12 +60,34 @@ def test_execute(self, requests_mock):
conn = boto3.client("s3")
conn.create_bucket(Bucket=self.s3_bucket)
operator = HttpToS3Operator(
- task_id="s3_to_file_sensor",
+ task_id="http_to_s3_operator",
+ http_conn_id=self.http_conn_id,
+ endpoint=self.endpoint,
+ s3_key=self.s3_key,
+ s3_bucket=self.s3_bucket,
+ dag=self.dag,
+ )
+ operator.execute(None)
+
+ objects_in_bucket = conn.list_objects(Bucket=self.s3_bucket,
Prefix=self.s3_key)
+ # there should be object found, and there should only be one object
found
+ assert len(objects_in_bucket["Contents"]) == 1
+ # the object found should be consistent with dest_key specified earlier
+ assert objects_in_bucket["Contents"][0]["Key"] == self.s3_key
+
+ @mock_aws
+ def test_execute_stream(self, requests_mock):
+ requests_mock.register_uri("GET", EXAMPLE_URL, content=self.response)
+ conn = boto3.client("s3")
+ conn.create_bucket(Bucket=self.s3_bucket)
+ operator = HttpToS3Operator(
+ task_id="http_to_s3_operator",
http_conn_id=self.http_conn_id,
endpoint=self.endpoint,
s3_key=self.s3_key,
s3_bucket=self.s3_bucket,
dag=self.dag,
+ extra_options={"stream": True},
)
operator.execute(None)
Review Comment:
The s3 client is already mocked right? Since we're using `@mock_aws`?
Basically the two tests are the same but in one you're providing your stream
option. You're testing that you get the expected number of objects but not
testing that they were actually transferred by the stream rather than the in
memory code path. If that path regressed I think this test would still pass.
But perhaps I'm reading it wrong!
--
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]