Skip to content

Commit 44316e0

Browse files
committed
request_product 인코딩 이슈 수정
한글 파라미터가 입력되었을때 인코딩 에러 발생하는 이슈 개선
1 parent 9f5d48a commit 44316e0

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ venv/
44
__pycache__/
55
build/
66
dist/
7-
easycodefpy.egg-info/
7+
easycodefpy.egg-info/
8+
.vscode/

easycodefpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = 'easycodefpy'
2-
__version__ = '0.0.2'
2+
__version__ = '0.0.3'
33
__author__ = 'CODEF'
44

55

easycodefpy/connector.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import requests
22
import base64
33
import json
4+
from urllib import parse
45
from typing import Union
56
from .properties import\
67
OAUTH_DOMAIN,\
@@ -45,11 +46,16 @@ def request_product(url: str, token: str, body_str: str) -> dict:
4546
}
4647
if token != '' and token is not None:
4748
headers['Authorization'] = 'Bearer ' + token
49+
50+
if body_str is not None and body_str != '':
51+
body_str = parse.quote(body_str)
52+
4853
with requests.post(url, data=body_str, headers=headers) as res:
4954
s_code = res.status_code
5055
codes = requests.codes
5156
if s_code == codes.ok:
52-
return res.json()
57+
data_str = parse.unquote_plus(res.text)
58+
return json.loads(data_str)
5359
elif s_code == codes.bad:
5460
return MESSAGE_BAD_REQUEST
5561
elif s_code == codes.unauthorized:

tests/test_connector.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,10 @@ def test_excute():
4343
assert res is not None
4444
assert exist_cid(res)
4545

46-
# def test_fail_set_token_must_unauth():
47-
# codef = Codef()
48-
# codef.public_key = 'public_key'
49-
# codef.set_client_info('id', 'secret')
50-
#
51-
# param = {
52-
# 'connectedId': '8PQI4dQ......hKLhTnZ',
53-
# 'organization': '0004',
54-
# 'identity': '1130000627',
55-
# }
56-
# product_url = '/v1/kr/card/b/account/card-list'
57-
58-
46+
def test_excute_by_unicode():
47+
codef = Codef()
48+
param = create_param_for_create_cid()
49+
param['dummy'] = '한글'
50+
res = execute(PATH_CREATE_ACCOUNT, param, codef, ServiceType.SANDBOX)
51+
assert res is not None
52+
assert exist_cid(res)

0 commit comments

Comments
 (0)