dstandish commented on a change in pull request #19665:
URL: https://github.com/apache/airflow/pull/19665#discussion_r764429805
##########
File path: tests/providers/amazon/aws/operators/test_redshift.py
##########
@@ -42,3 +47,69 @@ def test_redshift_operator(self, test_autocommit,
test_parameters, mock_get_hook
autocommit=test_autocommit,
parameters=test_parameters,
)
+
+
+class TestResumeClusterOperator(unittest.TestCase):
+ @staticmethod
+ def _create_clusters():
+ client = boto3.client('redshift', region_name='us-east-1')
+ client.create_cluster(
+ ClusterIdentifier='test_cluster_to_pause',
+ NodeType='dc1.large',
+ MasterUsername='admin',
+ MasterUserPassword='mock_password',
+ )
+ client.create_cluster(
+ ClusterIdentifier='test_cluster_to_resume',
+ NodeType='dc1.large',
+ MasterUsername='admin',
+ MasterUserPassword='mock_password',
+ )
+ if not client.describe_clusters()['Clusters']:
+ raise ValueError('AWS not properly mocked')
+
+ def test_init(self):
+ redshift_operator = RedshiftResumeClusterOperator(
+ task_id="task_test", cluster_identifier="test_cluster",
aws_conn_id="aws_conn_test"
+ )
+ assert redshift_operator.task_id == "task_test"
+ assert redshift_operator.cluster_identifier == "test_cluster"
+ assert redshift_operator.aws_conn_id == "aws_conn_test"
+
+ def test_resume_cluster(self):
Review comment:
I understand you might want to be able to use that library. But you
don't need to. And anyway just because you can't use that library, it doesn't
mean we waive our requirement that things be tested.
It is pretty straightforward to mock the return value from `cluster_status`.
Then you could have `get_conn` return a magicmock and assert that, on it,
pause_cluster is called.
--
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]