* Add option to to_query_str to encode lists as multiple occurences of the same parameter. * Add option to parse_query_string to not split comma-delimited values. * Add an option to RequestOptions for toggling csv parsing. In all cases, the options default to the previous behavior in order to avoid introducing any breaking changes. Co-Authored-By: Daniel Schwarz <qwesda@me.com> Co-Authored-By: Steven Ly <sly@openroad.ca> Co-Authored-By: Kurt Griffiths <inbox@kgriffs.com> Closes #749
38 lines
1010 B
Python
38 lines
1010 B
Python
import ddt
|
|
|
|
from falcon.request import RequestOptions
|
|
import falcon.testing as testing
|
|
|
|
|
|
@ddt.ddt
|
|
class TestRequestOptions(testing.TestBase):
|
|
|
|
def test_option_defaults(self):
|
|
options = RequestOptions()
|
|
|
|
self.assertFalse(options.keep_blank_qs_values)
|
|
self.assertFalse(options.auto_parse_form_urlencoded)
|
|
self.assertTrue(options.auto_parse_qs_csv)
|
|
|
|
@ddt.data(
|
|
'keep_blank_qs_values',
|
|
'auto_parse_form_urlencoded',
|
|
'auto_parse_qs_csv',
|
|
)
|
|
def test_options_toggle(self, option_name):
|
|
options = RequestOptions()
|
|
|
|
setattr(options, option_name, True)
|
|
self.assertTrue(getattr(options, option_name))
|
|
|
|
setattr(options, option_name, False)
|
|
self.assertFalse(getattr(options, option_name))
|
|
|
|
def test_incorrect_options(self):
|
|
options = RequestOptions()
|
|
|
|
def _assign_invalid():
|
|
options.invalid_option_and_attribute = True
|
|
|
|
self.assertRaises(AttributeError, _assign_invalid)
|