Skip to content

The "has_calls" is used in place of "assert_has_calls" in a few places #20453

Description

@potiuk

Body

As explained in #20428 (comment) we seem to have number (not big) of tests that use "has_calls" rather than "assert_has_calls".

😱 😱 😱 😱 😱 😱 😱 😱 😱

What "has_calls" does is acually calling "has_calls" method on the mock :) . Which make them no-assertion tests:

😱 😱 😱 😱 😱 😱 😱 😱 😱

The list of those tests:

  • ./tests/providers/google/common/hooks/test_base_google.py: mock_check_output.has_calls(
  • ./tests/providers/google/common/hooks/test_base_google.py: mock_check_output.has_calls(
  • ./tests/providers/google/cloud/transfers/test_sheets_to_gcs.py: mock_sheet_hook.return_value.get_values.has_calls(calls)
  • ./tests/providers/google/cloud/transfers/test_sheets_to_gcs.py: mock_upload_data.has_calls(calls)
  • ./tests/providers/google/cloud/hooks/test_bigquery.py: mock_poll_job_complete.has_calls(mock.call(running_job_id), mock.call(running_job_id))
  • ./tests/providers/google/cloud/hooks/test_bigquery.py: mock_schema.has_calls([mock.call(x, "") for x in ["field_1", "field_2"]])
  • ./tests/providers/google/cloud/hooks/test_bigquery.py: assert mock_insert.has_calls(
  • ./tests/providers/google/cloud/hooks/test_pubsub.py: publish_method.has_calls(calls)
  • ./tests/providers/google/cloud/hooks/test_cloud_memorystore.py: mock_get_conn.return_value.get_instance.has_calls(
  • ./tests/providers/google/cloud/hooks/test_cloud_memorystore.py: mock_get_conn.return_value.get_instance.has_calls(
  • ./tests/providers/google/cloud/hooks/test_cloud_memorystore.py: mock_get_conn.return_value.get_instance.has_calls(
  • ./tests/providers/google/cloud/hooks/test_dataproc.py: mock_get_job.has_calls(calls)
  • ./tests/providers/google/cloud/hooks/test_dataproc.py: mock_get_job.has_calls(calls)
  • ./tests/providers/google/suite/operators/test_sheets.py: mock_xcom.has_calls(calls)
  • ./tests/providers/http/operators/test_http.py: mock_info.has_calls(calls)
  • ./tests/providers/airbyte/hooks/test_airbyte.py: assert mock_get_job.has_calls(calls)
  • ./tests/providers/airbyte/hooks/test_airbyte.py: assert mock_get_job.has_calls(calls)
  • ./tests/providers/airbyte/hooks/test_airbyte.py: assert mock_get_job.has_calls(calls)
  • ./tests/providers/airbyte/hooks/test_airbyte.py: assert mock_get_job.has_calls(calls)
  • ./tests/providers/airbyte/hooks/test_airbyte.py: assert mock_get_job.has_calls(calls)

We should fix those tests and likelly add pre-commit to ban this.

Thanks to @jobegrabber for noticing it!

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions