Seokyun-Ha commented on code in PR #34071:
URL: https://github.com/apache/airflow/pull/34071#discussion_r1331138538
##########
tests/providers/databricks/hooks/test_databricks.py:
##########
@@ -616,6 +647,58 @@ def test_start_cluster(self, mock_requests):
timeout=self.hook.timeout_seconds,
)
+ @mock.patch("airflow.providers.databricks.hooks.databricks_base.requests")
+ def test_activate_cluster_with_running_state(self, mock_requests):
+ running_states = ["RUNNING", "RESIZING"]
+ json = {"cluster_id": CLUSTER_ID}
+ for state in running_states:
+ mock_requests.codes.ok = 200
+ mock_requests.get.return_value.json.return_value = {"state":
state, "state_message": ""}
+ self.hook.activate_cluster(json=json, polling=5, timeout=60)
+ mock_requests.get.assert_called_once_with(
+ get_cluster_endpoint(HOST),
+ json=None,
+ params={"cluster_id": CLUSTER_ID},
+ auth=HTTPBasicAuth(LOGIN, PASSWORD),
+ headers=self.hook.user_agent_header,
+ timeout=self.hook.timeout_seconds,
+ )
+ mock_requests.get.reset_mock()
Review Comment:
Great! We will change the code to use `@pytest.mark.parametrize()`. Thanks!
👍
##########
tests/providers/databricks/hooks/test_databricks.py:
##########
@@ -616,6 +647,58 @@ def test_start_cluster(self, mock_requests):
timeout=self.hook.timeout_seconds,
)
+ @mock.patch("airflow.providers.databricks.hooks.databricks_base.requests")
+ def test_activate_cluster_with_running_state(self, mock_requests):
+ running_states = ["RUNNING", "RESIZING"]
+ json = {"cluster_id": CLUSTER_ID}
+ for state in running_states:
+ mock_requests.codes.ok = 200
+ mock_requests.get.return_value.json.return_value = {"state":
state, "state_message": ""}
+ self.hook.activate_cluster(json=json, polling=5, timeout=60)
+ mock_requests.get.assert_called_once_with(
+ get_cluster_endpoint(HOST),
+ json=None,
+ params={"cluster_id": CLUSTER_ID},
+ auth=HTTPBasicAuth(LOGIN, PASSWORD),
+ headers=self.hook.user_agent_header,
+ timeout=self.hook.timeout_seconds,
+ )
+ mock_requests.get.reset_mock()
Review Comment:
Great! We will change the code to use `@pytest.mark.parametrize()`. Thanks!
👍
--
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]