fix: replace deprecated utcfromtimestamp (#1799) · googleapis/google-auth-library-python@e431f20
@@ -758,7 +758,7 @@ def test_default_state(self, get):
758758759759@mock.patch(
760760 "google.auth._helpers.utcnow",
761- return_value=datetime.datetime.utcfromtimestamp(0),
761+ return_value=_helpers.utcfromtimestamp(0),
762762 )
763763@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
764764@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -791,7 +791,7 @@ def test_make_authorization_grant_assertion(self, sign, get, utcnow):
791791792792@mock.patch(
793793 "google.auth._helpers.utcnow",
794- return_value=datetime.datetime.utcfromtimestamp(0),
794+ return_value=_helpers.utcfromtimestamp(0),
795795 )
796796@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
797797@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -823,7 +823,7 @@ def test_with_service_account(self, sign, get, utcnow):
823823824824@mock.patch(
825825 "google.auth._helpers.utcnow",
826- return_value=datetime.datetime.utcfromtimestamp(0),
826+ return_value=_helpers.utcfromtimestamp(0),
827827 )
828828@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
829829@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -879,7 +879,7 @@ def test_token_uri(self):
879879880880@mock.patch(
881881 "google.auth._helpers.utcnow",
882- return_value=datetime.datetime.utcfromtimestamp(0),
882+ return_value=_helpers.utcfromtimestamp(0),
883883 )
884884@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
885885@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1001,7 +1001,7 @@ def test_with_target_audience_integration(self):
1001100110021002@mock.patch(
10031003 "google.auth._helpers.utcnow",
1004- return_value=datetime.datetime.utcfromtimestamp(0),
1004+ return_value=_helpers.utcfromtimestamp(0),
10051005 )
10061006@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
10071007@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1040,7 +1040,7 @@ def test_with_quota_project(self, sign, get, utcnow):
1040104010411041@mock.patch(
10421042 "google.auth._helpers.utcnow",
1043- return_value=datetime.datetime.utcfromtimestamp(0),
1043+ return_value=_helpers.utcfromtimestamp(0),
10441044 )
10451045@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
10461046@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1062,7 +1062,7 @@ def test_with_token_uri(self, sign, get, utcnow):
1062106210631063@mock.patch(
10641064 "google.auth._helpers.utcnow",
1065- return_value=datetime.datetime.utcfromtimestamp(0),
1065+ return_value=_helpers.utcfromtimestamp(0),
10661066 )
10671067@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
10681068@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1170,7 +1170,7 @@ def test_with_quota_project_integration(self):
1170117011711171@mock.patch(
11721172 "google.auth._helpers.utcnow",
1173- return_value=datetime.datetime.utcfromtimestamp(0),
1173+ return_value=_helpers.utcfromtimestamp(0),
11741174 )
11751175@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
11761176@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1181,7 +1181,11 @@ def test_refresh_success(self, id_token_jwt_grant, sign, get, utcnow):
11811181 ]
11821182sign.side_effect = [b"signature"]
11831183id_token_jwt_grant.side_effect = [
1184- ("idtoken", datetime.datetime.utcfromtimestamp(3600), {})
1184+ (
1185+"idtoken",
1186+_helpers.utcfromtimestamp(3600),
1187+ {},
1188+ )
11851189 ]
1186119011871191request = mock.create_autospec(transport.Request, instance=True)
@@ -1194,7 +1198,7 @@ def test_refresh_success(self, id_token_jwt_grant, sign, get, utcnow):
1194119811951199# Check that the credentials have the token and proper expiration
11961200assert self.credentials.token == "idtoken"
1197-assert self.credentials.expiry == (datetime.datetime.utcfromtimestamp(3600))
1201+assert self.credentials.expiry == _helpers.utcfromtimestamp(3600)
1198120211991203# Check the credential info
12001204assert self.credentials.service_account_email == "service-account@example.com"
@@ -1205,7 +1209,7 @@ def test_refresh_success(self, id_token_jwt_grant, sign, get, utcnow):
1205120912061210@mock.patch(
12071211 "google.auth._helpers.utcnow",
1208- return_value=datetime.datetime.utcfromtimestamp(0),
1212+ return_value=_helpers.utcfromtimestamp(0),
12091213 )
12101214@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
12111215@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1232,7 +1236,7 @@ def test_refresh_error(self, sign, get, utcnow):
1232123612331237@mock.patch(
12341238 "google.auth._helpers.utcnow",
1235- return_value=datetime.datetime.utcfromtimestamp(0),
1239+ return_value=_helpers.utcfromtimestamp(0),
12361240 )
12371241@mock.patch("google.auth.compute_engine._metadata.get", autospec=True)
12381242@mock.patch("google.auth.iam.Signer.sign", autospec=True)
@@ -1243,7 +1247,11 @@ def test_before_request_refreshes(self, id_token_jwt_grant, sign, get, utcnow):
12431247 ]
12441248sign.side_effect = [b"signature"]
12451249id_token_jwt_grant.side_effect = [
1246- ("idtoken", datetime.datetime.utcfromtimestamp(3600), {})
1250+ (
1251+"idtoken",
1252+_helpers.utcfromtimestamp(3600),
1253+ {},
1254+ )
12471255 ]
1248125612491257request = mock.create_autospec(transport.Request, instance=True)
@@ -1312,7 +1320,7 @@ def test_get_id_token_from_metadata(
13121320 }
1313132113141322assert cred.token == SAMPLE_ID_TOKEN
1315-assert cred.expiry == datetime.datetime.utcfromtimestamp(SAMPLE_ID_TOKEN_EXP)
1323+assert cred.expiry == _helpers.utcfromtimestamp(SAMPLE_ID_TOKEN_EXP)
13161324assert cred._use_metadata_identity_endpoint
13171325assert cred._signer is None
13181326assert cred._token_uri is None