Skip to content

Commit

Permalink
Code cleanup - reported by Flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
enote-kane committed Apr 27, 2020
1 parent 168751b commit 94506b1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
1 change: 0 additions & 1 deletion fxa/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import base64
import hashlib
from binascii import hexlify
from six import string_types
from six.moves.urllib.parse import urlparse, urlunparse, urlencode, parse_qs

Expand Down
14 changes: 7 additions & 7 deletions fxa/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def wait_for_email(m):
# If everything went well, verify_email_code should return an empty json object
response = self.client.verify_email_code(m["headers"]["x-uid"],
m["headers"]["x-verify-code"])
self.assertEquals(response, {})
self.assertEqual(response, {})

def test_send_unblock_code(self):
acct = TestEmailAccount(email="block-{uniq}@{hostname}")
Expand All @@ -188,7 +188,7 @@ def test_send_unblock_code(self):

# Initiate sending unblock code
response = self.client.send_unblock_code(acct.email)
self.assertEquals(response, {})
self.assertEqual(response, {})

m = acct.wait_for_email(lambda m: "x-unblock-code" in m["headers"])
if not m:
Expand Down Expand Up @@ -302,16 +302,16 @@ def has_verify_code(m):

# Check that encryption keys have been preserved.
session2.fetch_keys()
self.assertEquals(self.session.keys, session2.keys)
self.assertEqual(self.session.keys, session2.keys)

def test_get_identity_assertion(self):
assertion = self.session.get_identity_assertion("http://example.com")
data = browserid.verify(assertion, audience="http://example.com")
self.assertEquals(data["status"], "okay")
self.assertEqual(data["status"], "okay")
expected_issuer = urlparse(self.session.server_url).hostname
self.assertEquals(data["issuer"], expected_issuer)
self.assertEqual(data["issuer"], expected_issuer)
expected_email = "{0}@{1}".format(self.session.uid, expected_issuer)
self.assertEquals(data["email"], expected_email)
self.assertEqual(data["email"], expected_email)

def test_get_identity_assertion_handles_duration(self):
millis = int(round(time.time() * 1000))
Expand All @@ -338,7 +338,7 @@ def test_get_identity_assertion_accepts_service(self):
assertion = self.session.get_identity_assertion("http://example.com",
service="test-me")
data = browserid.verify(assertion, audience="http://example.com")
self.assertEquals(data["status"], "okay")
self.assertEqual(data["status"], "okay")

def test_totp(self):
resp = self.session.totp_create()
Expand Down
4 changes: 2 additions & 2 deletions fxa/tests/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def test_xor(self):

def test_hkdf_namespace_handle_unicode_strings(self):
kw = hkdf_namespace(text_type("foobar"))
self.assertEquals(kw, b"identity.mozilla.com/picl/v1/foobar")
self.assertEqual(kw, b"identity.mozilla.com/picl/v1/foobar")

def test_hkdf_namespace_handle_bytes_strings(self):
kw = hkdf_namespace("foobar".encode('utf-8'))
self.assertEquals(kw, b"identity.mozilla.com/picl/v1/foobar")
self.assertEqual(kw, b"identity.mozilla.com/picl/v1/foobar")
37 changes: 19 additions & 18 deletions fxa/tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def authorization_callback(request):
def test_authorize_code_with_default_arguments(self):
assertion = "A_FAKE_ASSERTION"
code = self.client.authorize_code(assertion)
self.assertEquals(code, "qed")
self.assertEqual(code, "qed")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand All @@ -304,9 +304,9 @@ def test_authorize_code_with_default_arguments(self):
def test_authorize_code_with_explicit_scope(self):
assertion = "A_FAKE_ASSERTION"
code = self.client.authorize_code(assertion, scope="profile:email")
self.assertEquals(code, "qed")
self.assertEqual(code, "qed")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand All @@ -317,9 +317,9 @@ def test_authorize_code_with_explicit_scope(self):
def test_authorize_code_with_explicit_client_id(self):
assertion = "A_FAKE_ASSERTION"
code = self.client.authorize_code(assertion, client_id="cba")
self.assertEquals(code, "qed")
self.assertEqual(code, "qed")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": "cba",
"state": AnyStringValue(),
Expand All @@ -334,9 +334,9 @@ def test_authorize_code_with_pkce_challenge(self):
self.assertEqual(sorted(verifier),
["code_verifier"])
code = self.client.authorize_code(assertion, **challenge)
self.assertEquals(code, "qed")
self.assertEqual(code, "qed")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand All @@ -353,9 +353,9 @@ def test_authorize_code_with_session_object(self):
audience=TEST_SERVER_URL,
service=self.client.client_id
)
self.assertEquals(code, "qed")
self.assertEqual(code, "qed")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": "IDENTITY",
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand All @@ -377,9 +377,9 @@ def setUp(self):
def test_authorize_token_with_default_arguments(self):
assertion = "A_FAKE_ASSERTION"
token = self.client.authorize_token(assertion)
self.assertEquals(token, "izatoken")
self.assertEqual(token, "izatoken")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand All @@ -390,9 +390,9 @@ def test_authorize_token_with_default_arguments(self):
def test_authorize_token_with_explicit_scope(self):
assertion = "A_FAKE_ASSERTION"
token = self.client.authorize_token(assertion, scope="storage")
self.assertEquals(token, "izatoken")
self.assertEqual(token, "izatoken")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand All @@ -404,9 +404,9 @@ def test_authorize_token_with_explicit_scope(self):
def test_authorize_token_with_explicit_client_id(self):
assertion = "A_FAKE_ASSERTION"
token = self.client.authorize_token(assertion, client_id="cba")
self.assertEquals(token, "izatoken")
self.assertEqual(token, "izatoken")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": assertion,
"client_id": "cba",
"state": AnyStringValue(),
Expand All @@ -422,9 +422,9 @@ def test_authorize_token_with_session_object(self):
audience=TEST_SERVER_URL,
service=self.client.client_id
)
self.assertEquals(token, "izatoken")
self.assertEqual(token, "izatoken")
req_body = json.loads(_decoded(responses.calls[0].request.body))
self.assertEquals(req_body, {
self.assertEqual(req_body, {
"assertion": "IDENTITY",
"client_id": self.client.client_id,
"state": AnyStringValue(),
Expand Down Expand Up @@ -601,6 +601,7 @@ def test_monkey_patch_for_gevent(self):

fxa._utils.requests = old_requests


class AnyStringValue:

def __eq__(self, other):
Expand Down
18 changes: 9 additions & 9 deletions fxa/tests/test_requests_auth_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, *args, **kwargs):
return_value=mocked_core_client())
def test_audience_is_parsed(self, client_patch):
self.auth(Request())
self.assertEquals(self.auth.audience, "http://www.example.com/")
self.assertEqual(self.auth.audience, "http://www.example.com/")

@mock.patch('fxa.core.Client',
return_value=mocked_core_client())
Expand Down Expand Up @@ -86,12 +86,12 @@ def test_memory_cache_is_used(self, client_patch):

# First call should set the cache value
auth(Request())
self.assertEquals(client_patch.return_value.login.return_value.
get_identity_assertion.call_count, 1)
self.assertEqual(client_patch.return_value.login.return_value.
get_identity_assertion.call_count, 1)
# Second call should use the cache value
auth(Request())
self.assertEquals(client_patch.return_value.login.return_value.
get_identity_assertion.call_count, 1)
self.assertEqual(client_patch.return_value.login.return_value.
get_identity_assertion.call_count, 1)

@mock.patch('fxa.core.Client',
return_value=mocked_core_client())
Expand Down Expand Up @@ -157,13 +157,13 @@ def test_memory_cache_is_used(self, oauth_client_patch,
core_client_patch):
# First call should set the cache value
self.auth(Request())
self.assertEquals(core_client_patch.call_count, 1)
self.assertEquals(oauth_client_patch.call_count, 1)
self.assertEqual(core_client_patch.call_count, 1)
self.assertEqual(oauth_client_patch.call_count, 1)

# Second call should use the cache value
self.auth(Request())
self.assertEquals(core_client_patch.call_count, 1)
self.assertEquals(oauth_client_patch.call_count, 1)
self.assertEqual(core_client_patch.call_count, 1)
self.assertEqual(oauth_client_patch.call_count, 1)

@mock.patch('fxa.core.Client',
return_value=mocked_core_client())
Expand Down

0 comments on commit 94506b1

Please sign in to comment.