Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove 'six' #871

Merged
merged 3 commits into from
Sep 21, 2021
Merged
Changes from 1 commit
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
Next Next commit
chore: remove 'six'
  • Loading branch information
tseaver committed Sep 21, 2021
commit 754db5888fa11dc0642fd90922d6af1c08cb93eb
20 changes: 10 additions & 10 deletions tests/test_downscoped.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.

import datetime
import http.client
import json
import urllib

import mock
import pytest
from six.moves import http_client
from six.moves import urllib

from google.auth import _helpers
from google.auth import credentials
Expand Down Expand Up @@ -461,7 +461,7 @@ def make_credentials(source_credentials=SourceCredentials(), quota_project_id=No
)

@staticmethod
def make_mock_request(data, status=http_client.OK):
def make_mock_request(data, status=http.client.OK):
response = mock.create_autospec(transport.Response, instance=True)
response.status = status
response.data = json.dumps(data).encode("utf-8")
Expand Down Expand Up @@ -521,7 +521,7 @@ def test_refresh(self, unused_utcnow):
"requested_token_type": REQUESTED_TOKEN_TYPE,
"options": urllib.parse.quote(json.dumps(CREDENTIAL_ACCESS_BOUNDARY_JSON)),
}
request = self.make_mock_request(status=http_client.OK, data=response)
request = self.make_mock_request(status=http.client.OK, data=response)
source_credentials = SourceCredentials()
credentials = self.make_credentials(source_credentials=source_credentials)

Expand Down Expand Up @@ -563,7 +563,7 @@ def test_refresh_without_response_expires_in(self, unused_utcnow):
"requested_token_type": REQUESTED_TOKEN_TYPE,
"options": urllib.parse.quote(json.dumps(CREDENTIAL_ACCESS_BOUNDARY_JSON)),
}
request = self.make_mock_request(status=http_client.OK, data=response)
request = self.make_mock_request(status=http.client.OK, data=response)
credentials = self.make_credentials(source_credentials=source_credentials)

# Spy on calls to source credentials refresh to confirm the expected request
Expand All @@ -583,7 +583,7 @@ def test_refresh_without_response_expires_in(self, unused_utcnow):

def test_refresh_token_exchange_error(self):
request = self.make_mock_request(
status=http_client.BAD_REQUEST, data=ERROR_RESPONSE
status=http.client.BAD_REQUEST, data=ERROR_RESPONSE
)
credentials = self.make_credentials()

Expand Down Expand Up @@ -612,7 +612,7 @@ def test_refresh_source_credentials_refresh_error(self):

def test_apply_without_quota_project_id(self):
headers = {}
request = self.make_mock_request(status=http_client.OK, data=SUCCESS_RESPONSE)
request = self.make_mock_request(status=http.client.OK, data=SUCCESS_RESPONSE)
credentials = self.make_credentials()

credentials.refresh(request)
Expand All @@ -624,7 +624,7 @@ def test_apply_without_quota_project_id(self):

def test_apply_with_quota_project_id(self):
headers = {"other": "header-value"}
request = self.make_mock_request(status=http_client.OK, data=SUCCESS_RESPONSE)
request = self.make_mock_request(status=http.client.OK, data=SUCCESS_RESPONSE)
credentials = self.make_credentials(quota_project_id=QUOTA_PROJECT_ID)

credentials.refresh(request)
Expand All @@ -638,7 +638,7 @@ def test_apply_with_quota_project_id(self):

def test_before_request(self):
headers = {"other": "header-value"}
request = self.make_mock_request(status=http_client.OK, data=SUCCESS_RESPONSE)
request = self.make_mock_request(status=http.client.OK, data=SUCCESS_RESPONSE)
credentials = self.make_credentials()

# First call should call refresh, setting the token.
Expand All @@ -662,7 +662,7 @@ def test_before_request(self):
@mock.patch("google.auth._helpers.utcnow")
def test_before_request_expired(self, utcnow):
headers = {}
request = self.make_mock_request(status=http_client.OK, data=SUCCESS_RESPONSE)
request = self.make_mock_request(status=http.client.OK, data=SUCCESS_RESPONSE)
credentials = self.make_credentials()
credentials.token = "token"
utcnow.return_value = datetime.datetime.min
Expand Down