上記あるように、以下のテストコードでpayloadの値がrequest.formで取得できません。
ImmutableMultiDict([]) というかんじで空で返ってきてしまいます。
何度もデバックしてもわからないため、何かチェックすべき点があればご教示頂けませんでしょうか?
python
def test_grant_type(app): path = '/oauth/token' payload = {'grant_type': 'client_credentials', 'scope': 'test_user'} auth_header = "client_id:client_secret" b64val = base64.b64encode(auth_header.encode('UTF-8')) headers = {'Authorization': 'Basic %s' % b64val.decode('UTF-8')} with app.test_request_context(path, method="POST") as req: req.request.args = payload req.request.headers = headers import pdb; pdb.set_trace() client_id = "test_user" assert "test_account_id"==get_grant_type(req.request, client_id)
エラー
> /Users/t/local/c/tests/auth.py(149)test_grant_type() -> client_id = "test_user" (Pdb) p req.request.form ImmutableMultiDict([]) (Pdb) p request <Request 'http://localhost/' [GET]> (Pdb) p req.request <Request 'http://localhost/oauth/token' [POST]> (Pdb) p req.request.args {'grant_type': 'client_credentials', 'scope': 'test_user'}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。