Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11e2cfc
commit 54f56e5
Showing
4 changed files
with
81 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
from flask import Flask, request | ||
|
||
from flask_ripozo.dispatcher import get_request_query_body_args | ||
|
||
import json | ||
import unittest | ||
|
||
|
||
class TestDispatcherFlaskIntegration(unittest.TestCase): | ||
def test_get_request_body_args(self): | ||
""" | ||
Tests getting the request body args | ||
from a flask request object. | ||
""" | ||
app = Flask('myapp') | ||
body = dict(x=1) | ||
with app.test_request_context('/', data=json.dumps(body), content_type='application/json'): | ||
q, b = get_request_query_body_args(request) | ||
self.assertDictEqual(b, body) | ||
|
||
with app.test_request_context('/', data=body): # Form encoded | ||
q, b = get_request_query_body_args(request) | ||
self.assertDictEqual(b, dict(x=['1'])) | ||
|
||
def test_get_request_body_args_nested(self): | ||
""" | ||
Tests getting nested body args which seems to | ||
be handled slightly differnetly. | ||
""" | ||
app = Flask('myapp') | ||
body = dict(x=1, y=dict(x=1)) | ||
with app.test_request_context('/', data=json.dumps(body), content_type='application/json'): | ||
q, b = get_request_query_body_args(request) | ||
self.assertDictEqual(b, body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters