Skip to content

Commit 9f5dba1

Browse files
committed
HTTP not 200에 raise할 HttpError 생성
1 parent d17d3db commit 9f5dba1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

iamport/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ def __init__(self, code=None, message=None):
2323
self.code = code
2424
self.message = message
2525

26+
class HttpError(Exception):
27+
def __init__(self, code=None, reason=None):
28+
self.code = code
29+
self.reason = reason
30+
2631
@staticmethod
2732
def get_response(response):
2833
if response.status_code != requests.codes.ok:
29-
return {}
34+
raise Iamport.HttpError(response.status_code, response.reason)
3035
result = response.json()
3136
if result['code'] != 0:
3237
raise Iamport.ResponseError(result.get('code'), result.get('message'))

tests/test_find.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def test_find(iamport):
66
with pytest.raises(KeyError):
77
iamport.find()
8-
result = iamport.find(imp_uid='test')
9-
assert dict == type(result)
10-
result = iamport.find(merchant_uid='test')
11-
assert dict == type(result)
8+
with pytest.raises(iamport.HttpError):
9+
iamport.find(imp_uid='test')
10+
with pytest.raises(iamport.HttpError):
11+
iamport.find(merchant_uid='âàáaā')

0 commit comments

Comments
 (0)