Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python: ['3.8']
python: ['3.7', '3.8']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1722): `test_aiohttp_requests` depend on
# aiohttp < 3.10.0 which is a bug. Investigate and remove the pinned aiohttp version.
"aiohttp < 3.10.0",
"mock >= 4.0.0; python_version < '3.8'",
"freezegun",
]

extras = {
Expand Down
2 changes: 1 addition & 1 deletion tests/compute_engine/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ def test_get_id_token_from_metadata(
)
cred.refresh(request=mock.Mock())

assert get.call_args.kwargs["headers"] == {
assert get.call_args[1]["headers"] == {
"x-goog-api-client": ID_TOKEN_REQUEST_METRICS_HEADER_VALUE
}

Expand Down
2 changes: 1 addition & 1 deletion tests/oauth2/test_webauthn_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_success_get_assertion(os_get_stub, subprocess_run_stub):
os_get_stub.assert_called_once()
subprocess_run_stub.assert_called_once()

stdin_input = subprocess_run_stub.call_args.kwargs["input"]
stdin_input = subprocess_run_stub.call_args[1]["input"]
input_json_len_le = stdin_input[:4]
input_json_len = struct.unpack("<I", input_json_len_le)[0]
input_json = stdin_input[4:]
Expand Down
11 changes: 9 additions & 2 deletions tests/test__exponential_backoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from unittest import mock
import sys

if sys.version_info >= (3, 8):
from unittest import mock
from unittest.mock import AsyncMock
else: # pragma: NO COVER
import mock
from mock import AsyncMock

import pytest # type: ignore

Expand Down Expand Up @@ -58,7 +65,7 @@ def test_minimum_total_attempts():


@pytest.mark.asyncio
@mock.patch("asyncio.sleep", return_value=None)
@mock.patch("asyncio.sleep", new_callable=AsyncMock)
async def test_exponential_backoff_async(mock_time_async):
eb = _exponential_backoff.AsyncExponentialBackoff()
curr_wait = eb._current_wait_in_seconds
Expand Down
10 changes: 6 additions & 4 deletions tests/test_impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test_refresh_success(
assert credentials.valid
assert not credentials.expired
assert (
request.call_args.kwargs["headers"]["x-goog-api-client"]
request.call_args[1]["headers"]["x-goog-api-client"]
== ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE
)

Expand Down Expand Up @@ -1075,7 +1075,7 @@ def test_id_token_metrics(self, mock_donor_credentials):
ID_TOKEN_EXPIRY
)
assert (
mock_post.call_args.kwargs["headers"]["x-goog-api-client"]
mock_post.call_args[1]["headers"]["x-goog-api-client"]
== ID_TOKEN_REQUEST_METRICS_HEADER_VALUE
)

Expand Down Expand Up @@ -1145,9 +1145,11 @@ def _test_id_token_helper(
id_creds = id_creds.from_credentials(target_credentials=target_credentials)
id_creds.refresh(request)

args = mock_authorizedsession_idtoken.call_args.args
# In Python 3.7, self might not be in call_args for autospecced methods
args = mock_authorizedsession_idtoken.call_args[0]

assert args[2] == expected_url
# Look for expected_url in args
assert expected_url in args

assert id_creds.token == ID_TOKEN_DATA
assert id_creds._include_email is True
Expand Down
8 changes: 7 additions & 1 deletion tests/transport/aio/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
# limitations under the License.

import asyncio
from unittest.mock import AsyncMock, Mock, patch
import sys

if sys.version_info >= (3, 8):
from unittest.mock import Mock, patch, AsyncMock
else: # pragma: NO COVER
from unittest.mock import Mock, patch
from mock import AsyncMock

from aioresponses import aioresponses # type: ignore
import pytest # type: ignore
Expand Down
5 changes: 4 additions & 1 deletion tests/transport/aio/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,12 @@ async def test_request_max_allowed_time_exceeded_error(self):
@pytest.mark.parametrize("retry_status", DEFAULT_RETRYABLE_STATUS_CODES)
@pytest.mark.asyncio
async def test_request_max_retries(self, retry_status):
async def async_sleep(delay):
pass

mocked_response = MockResponse(status_code=retry_status)
auth_request = MockRequest(mocked_response)
with patch("asyncio.sleep", return_value=None):
with patch("asyncio.sleep", side_effect=async_sleep):
authed_session = sessions.AsyncAuthorizedSession(
self.credentials, auth_request
)
Expand Down
Loading
Loading