Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def test_parse_host_with_scheme(self):
assert host == HOST

def test_init_bad_retry_limit(self):
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Retry limit must be greater than or equal to 1"):
DatabricksHook(retry_limit=0)

def test_do_api_call_retries_with_retryable_error(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,8 @@ def test_query(
],
)
def test_no_query(databricks_hook, empty_statement):
with pytest.raises(ValueError) as err:
with pytest.raises(ValueError, match="List of SQL statements is empty"):
databricks_hook.run(sql=empty_statement)
assert err.value.args[0] == "List of SQL statements is empty"


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2404,10 +2404,10 @@ def test_both_new_and_existing_cluster_set(self):
existing_cluster_id="existing_cluster_id",
databricks_conn_id="test_conn_id",
)
with pytest.raises(ValueError) as exc_info:
with pytest.raises(
ValueError, match="Both new_cluster and existing_cluster_id are set. Only one should be set."
):
operator._get_run_json()
exception_message = "Both new_cluster and existing_cluster_id are set. Only one should be set."
assert str(exc_info.value) == exception_message

def test_both_new_and_existing_cluster_unset(self):
operator = DatabricksNotebookOperator(
Expand All @@ -2416,10 +2416,8 @@ def test_both_new_and_existing_cluster_unset(self):
source="test_source",
databricks_conn_id="test_conn_id",
)
with pytest.raises(ValueError) as exc_info:
with pytest.raises(ValueError, match="Must specify either existing_cluster_id or new_cluster."):
operator._get_run_json()
exception_message = "Must specify either existing_cluster_id or new_cluster."
assert str(exc_info.value) == exception_message

def test_job_runs_forever_by_default(self):
operator = DatabricksNotebookOperator(
Expand All @@ -2442,13 +2440,12 @@ def test_zero_execution_timeout_raises_error(self):
existing_cluster_id="existing_cluster_id",
execution_timeout=timedelta(seconds=0),
)
with pytest.raises(ValueError) as exc_info:
with pytest.raises(
ValueError,
match="If you've set an `execution_timeout` for the task, ensure it's not `0`. "
"Set it instead to `None` if you desire the task to run indefinitely.",
):
operator._get_run_json()
exception_message = (
"If you've set an `execution_timeout` for the task, ensure it's not `0`. "
"Set it instead to `None` if you desire the task to run indefinitely."
)
assert str(exc_info.value) == exception_message

def test_extend_workflow_notebook_packages(self):
"""Test that the operator can extend the notebook packages of a Databricks workflow task group."""
Expand Down
11 changes: 8 additions & 3 deletions providers/dbt/cloud/tests/unit/dbt/cloud/hooks/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
TokenAuth,
fallback_to_default_account,
)
from airflow.utils import timezone

try:
from airflow.sdk import timezone
except ImportError:
from airflow.utils import timezone # type: ignore[attr-defined,no-redef]

ACCOUNT_ID_CONN = "account_id_conn"
NO_ACCOUNT_ID_CONN = "no_account_id_conn"
Expand All @@ -57,6 +61,7 @@

BASE_URL = "https://cloud.getdbt.com/"
SINGLE_TENANT_URL = "https://single.tenant.getdbt.com/"
NOT_VAILD_DBT_STATUS = "not a valid DbtCloudJobRunStatus"

DEFAULT_LIST_PROJECTS_RESPONSE = {
"data": [
Expand Down Expand Up @@ -127,7 +132,7 @@ def test_valid_job_run_status(self, statuses):
ids=_get_ids(invalid_job_run_statuses),
)
def test_invalid_job_run_status(self, statuses):
with pytest.raises(ValueError):
with pytest.raises(ValueError, match=NOT_VAILD_DBT_STATUS):
DbtCloudJobRunStatus.check_is_valid(statuses)

@pytest.mark.parametrize(
Expand All @@ -144,7 +149,7 @@ def test_valid_terminal_job_run_status(self, statuses):
ids=_get_ids(invalid_job_run_statuses),
)
def test_invalid_terminal_job_run_status(self, statuses):
with pytest.raises(ValueError):
with pytest.raises(ValueError, match=NOT_VAILD_DBT_STATUS):
DbtCloudJobRunStatus.check_is_valid(statuses)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,5 @@ def test_send_not_support_type(self):
"message": "Airflow dingding text message remind no one",
}
hook = DingdingHook(**config)
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="receive not_support_type"):
hook.send()
Loading