turbaszek commented on a change in pull request #10947: URL: https://github.com/apache/airflow/pull/10947#discussion_r490838264
########## File path: tests/providers/amazon/aws/sensors/test_glacier.py ########## @@ -0,0 +1,67 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import unittest + +import mock + +from airflow import AirflowException +from airflow.providers.amazon.aws.sensors.glacier import GlacierJobOperationSensor + +TASK_ID = "test_glacier_sensor" +AWS_CONN_ID = "aws_default" +VAULT_NAME = "airflow" +JOB_ID = "1a2b3c4d" +POKE_INTERVAL = 60 * 20 +SUCCESS = "Succeeded" +IN_PROGRESS = "InProgress" +FAIL = "unknown_status" + + +class TestAmazonGlacierSensor(unittest.TestCase): + def setUp(self): + self.op = GlacierJobOperationSensor( + task_id='test_athena_sensor', + aws_conn_id='aws_default', + vault_name="airflow", + job_id="1a2b3c4d", + poke_interval=60 * 20, + ) + + @mock.patch( + "airflow.providers.amazon.aws.sensors.glacier.GlacierHook.describe_job", + side_effect=[{"Action": "", "StatusCode": "Succeeded"}], + ) + def test_poke_succeeded(self, hook_mock): # pylint: disable=unused-argument + self.assertTrue(self.op.poke(None)) + + @mock.patch( + "airflow.providers.amazon.aws.sensors.glacier.GlacierHook.describe_job", + side_effect=[{"Action": "", "StatusCode": "InProgress"}], + ) + def test_poke_in_progress(self, hook_mock): # pylint: disable=unused-argument Review comment: ```suggestion def test_poke_in_progress(self, _): ``` Or `mock_hook` as per pylint rc: ``` # Argument names that match this expression will be ignored. Default to name # with leading underscore. ignored-argument-names=_.*|^ignored_|^unused_|^kwargs|^args|^mock_.+ ``` ########## File path: tests/providers/amazon/aws/sensors/test_glacier.py ########## @@ -0,0 +1,67 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import unittest + +import mock + +from airflow import AirflowException +from airflow.providers.amazon.aws.sensors.glacier import GlacierJobOperationSensor + +TASK_ID = "test_glacier_sensor" +AWS_CONN_ID = "aws_default" +VAULT_NAME = "airflow" +JOB_ID = "1a2b3c4d" +POKE_INTERVAL = 60 * 20 +SUCCESS = "Succeeded" +IN_PROGRESS = "InProgress" +FAIL = "unknown_status" + + +class TestAmazonGlacierSensor(unittest.TestCase): + def setUp(self): + self.op = GlacierJobOperationSensor( + task_id='test_athena_sensor', + aws_conn_id='aws_default', + vault_name="airflow", + job_id="1a2b3c4d", + poke_interval=60 * 20, + ) + + @mock.patch( + "airflow.providers.amazon.aws.sensors.glacier.GlacierHook.describe_job", + side_effect=[{"Action": "", "StatusCode": "Succeeded"}], + ) + def test_poke_succeeded(self, hook_mock): # pylint: disable=unused-argument + self.assertTrue(self.op.poke(None)) + + @mock.patch( + "airflow.providers.amazon.aws.sensors.glacier.GlacierHook.describe_job", + side_effect=[{"Action": "", "StatusCode": "InProgress"}], + ) + def test_poke_in_progress(self, hook_mock): # pylint: disable=unused-argument + self.assertFalse(self.op.poke(None)) + + @mock.patch( + "airflow.providers.amazon.aws.sensors.glacier.GlacierHook.describe_job", + side_effect=[{"Action": "", "StatusCode": ""}], + ) + def test_poke_fail(self, hook_mock): # pylint: disable=unused-argument Review comment: ```suggestion def test_poke_fail(self, _): ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
