Skip to content

Commit d01cc94

Browse files
authored
Fixes several failing tests after broken main (#17222)
Several problems slipped through after recent broken main event end they were merged with failing tests. This PR fixes it as well as brings correct approach for "initialize-local-virtualenv" to get constraints from sources rather than PyPI constraints, which makes it easier to synchronize with latest versions of depenendencies.
1 parent babc425 commit d01cc94

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

β€Žairflow/providers/google/ads/hooks/ads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _search(
239239
request = self._get_client.get_type("SearchGoogleAdsRequest")
240240
request.customer_id = client_id
241241
request.query = query
242-
request.page_size = 10000
242+
request.page_size = page_size
243243

244244
iterator = service.search(request=request)
245245
iterators.append(iterator)

β€Žbreeze

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ function breeze::initialize_virtualenv() {
255255
echo
256256
pushd "${AIRFLOW_SOURCES}" >/dev/null 2>&1 || exit 1
257257
set +e
258-
pip install -e ".[devel]" \
259-
--constraint "https://raw.githubusercontent.com/${CONSTRAINTS_GITHUB_REPOSITORY}/${DEFAULT_CONSTRAINTS_BRANCH}/constraints-${PYTHON_MAJOR_MINOR_VERSION}.txt"
258+
pip install -e ".[devel_all]" \
259+
--constraint "https://raw.githubusercontent.com/${CONSTRAINTS_GITHUB_REPOSITORY}/${DEFAULT_CONSTRAINTS_BRANCH}/constraints-source-providers-${PYTHON_MAJOR_MINOR_VERSION}.txt"
260260
res=$?
261261
set -e
262262
popd

β€Žtests/providers/amazon/aws/hooks/test_s3.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import pytest
2727
from botocore.exceptions import ClientError, NoCredentialsError
2828

29-
from airflow.exceptions import AirflowException
3029
from airflow.models import Connection
3130
from airflow.providers.amazon.aws.hooks.s3 import S3Hook, provide_bucket_name, unify_bucket_name_and_key
3231

@@ -366,12 +365,10 @@ def test_function(self, bucket_name=None):
366365
assert test_bucket_name == 'bucket'
367366

368367
def test_delete_objects_key_does_not_exist(self, s3_bucket):
368+
# The behaviour of delete changed in recent version of s3 mock libraries.
369+
# It will succeed idempotently
369370
hook = S3Hook()
370-
with pytest.raises(AirflowException) as ctx:
371-
hook.delete_objects(bucket=s3_bucket, keys=['key-1'])
372-
373-
assert isinstance(ctx.value, AirflowException)
374-
assert str(ctx.value) == "Errors when deleting: ['key-1']"
371+
hook.delete_objects(bucket=s3_bucket, keys=['key-1'])
375372

376373
def test_delete_objects_one_key(self, mocked_s3_res, s3_bucket):
377374
key = 'key-1'

β€Žtests/providers/google/ads/hooks/test_ads.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
from unittest import mock
19+
from unittest.mock import PropertyMock
1920

2021
import pytest
2122

@@ -56,18 +57,21 @@ def test_get_service(self, mock_client, mock_hook):
5657
@mock.patch("airflow.providers.google.ads.hooks.ads.GoogleAdsClient")
5758
def test_search(self, mock_client, mock_hook):
5859
service = mock_client.load_from_dict.return_value.get_service.return_value
60+
mock_client.load_from_dict.return_value.get_type.side_effect = [PropertyMock(), PropertyMock()]
61+
client_ids = ["1", "2"]
5962
rows = ["row1", "row2"]
6063
service.search.side_effects = rows
6164

6265
# Here we mock _extract_rows to assert calls and
6366
# avoid additional __iter__ calls
6467
mock_hook._extract_rows = list
65-
6668
query = "QUERY"
67-
client_ids = ["1", "2"]
68-
mock_hook.search(client_ids=client_ids, query="QUERY", page_size=2)
69-
expected_calls = [mock.call(c, query=query, page_size=2) for c in client_ids]
70-
service.search.assert_has_calls(expected_calls)
69+
mock_hook.search(client_ids=client_ids, query=query, page_size=2)
70+
for i, client_id in enumerate(client_ids):
71+
name, args, kwargs = service.search.mock_calls[i]
72+
assert kwargs['request'].customer_id == client_id
73+
assert kwargs['request'].query == query
74+
assert kwargs['request'].page_size == 2
7175

7276
def test_extract_rows(self, mock_hook):
7377
iterators = [[1, 2, 3], [4, 5, 6]]

β€Žtests/providers/google/cloud/hooks/test_bigquery.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,15 @@ def test_create_external_table_with_kms(self, mock_create):
17611761
allow_jagged_rows = False
17621762
encoding = "UTF-8"
17631763
labels = {'label1': 'test1', 'label2': 'test2'}
1764-
schema_fields = [{'mode': 'REQUIRED', 'name': 'id', 'type': 'STRING', 'description': None}]
1764+
schema_fields = [
1765+
{
1766+
'mode': 'REQUIRED',
1767+
'name': 'id',
1768+
'type': 'STRING',
1769+
'description': None,
1770+
'policyTags': {'names': []},
1771+
}
1772+
]
17651773
encryption_configuration = {"kms_key_name": "projects/p/locations/l/keyRings/k/cryptoKeys/c"}
17661774

17671775
self.hook.create_external_table(

0 commit comments

Comments
 (0)