Skip to content

Commit 78ada58

Browse files
committed
update tests
1 parent ccac289 commit 78ada58

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
import json
66
import logging
7-
from datetime import timedelta, timezone
7+
from datetime import timedelta
88
from typing import Optional, Union
9-
from unittest.mock import Mock
9+
from unittest.mock import Mock, PropertyMock
1010

1111
import freezegun
1212
import pytest
@@ -236,6 +236,7 @@ def test_refresh_request_body_with_keys_override(self):
236236
}
237237
assert body == expected
238238

239+
@freezegun.freeze_time("2022-01-01")
239240
def test_refresh_access_token(self, mocker):
240241
oauth = Oauth2Authenticator(
241242
token_refresh_endpoint="https://refresh_endpoint.com",
@@ -281,6 +282,15 @@ def test_refresh_access_token(self, mocker):
281282
assert isinstance(expires_in, str)
282283
assert ("access_token", "2022-04-24T00:00:00Z") == (token, expires_in)
283284

285+
# Test with no expires_in
286+
mocker.patch.object(
287+
resp,
288+
"json",
289+
return_value={"access_token": "access_token"},
290+
)
291+
token, expires_in = oauth.refresh_access_token()
292+
assert expires_in == "3600"
293+
284294
# Test with nested access_token and expires_in as str(int)
285295
mocker.patch.object(
286296
resp,
@@ -393,8 +403,10 @@ def test_refresh_access_token_when_headers_provided(self, mocker):
393403
"YYYY-MM-DDTHH:mm:ss.SSSSSSZ",
394404
AirbyteDateTime(year=2022, month=2, day=12),
395405
),
406+
(None, None, AirbyteDateTime(year=2022, month=1, day=1, hour=1)),
407+
(None, "YYYY-MM-DD", AirbyteDateTime(year=2022, month=1, day=1, hour=1)),
396408
],
397-
ids=["seconds", "string_of_seconds", "simple_date", "simple_datetime"],
409+
ids=["seconds", "string_of_seconds", "simple_date", "simple_datetime", "default_behavior", "default_behavior_with_format"],
398410
)
399411
@freezegun.freeze_time("2022-01-01")
400412
def test_parse_refresh_token_lifespan(

0 commit comments

Comments
 (0)