Skip to content

Commit

Permalink
Fix issues reported by ruff team before new ruff rules are out (apach…
Browse files Browse the repository at this point in the history
…e#44460)

Ruff team is using Airflow as one of the "ecosystem" benchmarks
for new rules they developed and reported the issues to us in
the apache#44455 discussion. This PR addresses those issues that are still
there (some of the reported tests were removed earlier today when
we removed AIP-44 code in apache#44454
  • Loading branch information
potiuk authored Nov 28, 2024
1 parent 1fdaebd commit 5e38319
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion providers/tests/amazon/aws/hooks/test_base_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ def _non_retryable_test(thing):
class TestRetryDecorator: # ptlint: disable=invalid-name
def test_do_nothing_on_non_exception(self):
result = _retryable_test(lambda: 42)
assert result, 42
assert result == 42

@mock.patch("time.sleep", return_value=0)
def test_retry_on_exception(self, _):
Expand Down
4 changes: 2 additions & 2 deletions providers/tests/google/cloud/sensors/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_gcs_object_existence_sensor_return_value(self, mock_defer, mock_hook):
)
mock_hook.return_value.list.return_value = True
return_value = task.execute(mock.MagicMock())
assert return_value, True
assert return_value

@mock.patch("airflow.providers.google.cloud.sensors.gcs.GCSHook")
def test_should_pass_argument_to_hook(self, mock_hook):
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_gcs_object_existence_sensor_execute_complete_return_value(self):
context=None, event={"status": "success", "message": "Job completed"}
)
mock_log_info.assert_called_with("File %s was found in bucket %s.", TEST_OBJECT, TEST_BUCKET)
assert return_value, True
assert return_value


class TestGoogleCloudStorageObjectUpdatedSensor:
Expand Down
2 changes: 1 addition & 1 deletion providers/tests/google/common/hooks/test_base_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _retryable_test_with_temporary_quota_retry(thing):
class TestQuotaRetry:
def test_do_nothing_on_non_error(self):
result = _retryable_test_with_temporary_quota_retry(lambda: 42)
assert result, 42
assert result == 42

def test_retry_on_exception(self):
message = "POST https://translation.googleapis.com/language/translate/v2: User Rate Limit Exceeded"
Expand Down
4 changes: 2 additions & 2 deletions tests/api_connexion/endpoints/test_task_instance_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,8 +1366,8 @@ def test_should_respond_200_with_reset_dag_run(self, session):
]
for task_instance in expected_response:
assert task_instance in response.json["task_instances"]
assert 6 == len(response.json["task_instances"])
assert 0 == failed_dag_runs, 0
assert len(response.json["task_instances"]) == 6
assert failed_dag_runs == 0
_check_last_log(session, dag_id=dag_id, event="api.post_clear_task_instances", logical_date=None)

def test_should_respond_200_with_dag_run_id(self, session):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1955,8 +1955,8 @@ def test_should_respond_200_with_reset_dag_run(self, test_client, session):
]
for task_instance in expected_response:
assert task_instance in response.json()["task_instances"]
assert 6 == response.json()["total_entries"]
assert 0 == failed_dag_runs, 0
assert response.json()["total_entries"] == 6
assert failed_dag_runs == 0

def test_should_respond_200_with_dag_run_id(self, test_client, session):
dag_id = "example_python_operator"
Expand Down Expand Up @@ -2012,7 +2012,7 @@ def test_should_respond_200_with_dag_run_id(self, test_client, session):
},
]
assert response.json()["task_instances"] == expected_response
assert 1 == response.json()["total_entries"]
assert response.json()["total_entries"] == 1

def test_should_respond_200_with_include_past(self, test_client, session):
dag_id = "example_python_operator"
Expand Down Expand Up @@ -2177,7 +2177,7 @@ def test_should_respond_200_with_include_future(self, test_client, session):
]
for task_instance in expected_response:
assert task_instance in response.json()["task_instances"]
assert 6 == response.json()["total_entries"]
assert response.json()["total_entries"] == 6

def test_should_respond_404_for_nonexistent_dagrun_id(self, test_client, session):
dag_id = "example_python_operator"
Expand Down

0 comments on commit 5e38319

Please sign in to comment.