Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit e2ff696

Browse files
committed
Made is_error_message into a function instead of a method.
1 parent 38b3918 commit e2ff696

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/oidcmsg/oauth2/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
logger = logging.getLogger(__name__)
1616

1717

18+
def is_error_message(msg):
19+
if 'error' in msg:
20+
return True
21+
else:
22+
return False
23+
24+
1825
class ResponseMessage(Message):
1926
"""
2027
The basic error response
@@ -23,12 +30,6 @@ class ResponseMessage(Message):
2330
"error_description": SINGLE_OPTIONAL_STRING,
2431
"error_uri": SINGLE_OPTIONAL_STRING}
2532

26-
def is_error_message(self):
27-
if 'error' in self:
28-
return True
29-
else:
30-
return False
31-
3233

3334
class AuthorizationErrorResponse(ResponseMessage):
3435
"""

tests/test_5_oauth2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from oidcmsg.message import sp_sep_list_deserializer
1515

1616
from oidcmsg.oauth2 import factory
17+
from oidcmsg.oauth2 import is_error_message
1718
from oidcmsg.oauth2 import AccessTokenRequest
1819
from oidcmsg.oauth2 import AccessTokenResponse
1920
from oidcmsg.oauth2 import AuthorizationErrorResponse
@@ -508,12 +509,12 @@ def test_error_message(self):
508509
assert ue_str != ueo_str
509510
assert "error_message" not in ueo_str
510511
assert "error_message" in ue_str
511-
assert err.is_error_message()
512+
assert is_error_message(err)
512513

513514
def test_auth_error_message(self):
514515
resp = AuthorizationResponse(error="invalid_request",
515516
error_description="Something was missing")
516-
assert resp.is_error_message()
517+
assert is_error_message(resp)
517518

518519

519520
def test_factory():

0 commit comments

Comments
 (0)