def test_sort_schema_simple(self): srtd = util.sort_schema({ '5': '5', '1': '1', '3': '3', }) self.assertEqual(['1','3','5'], list(srtd))
def decorator(fn): validate_schema(schema) wrapper = wrap_request_params(fn, schema) record_schemas(fn, wrapper, location, params_schema=sort_schema(schema)) return wrapper
def decorator(fn): validate_schema(schema) wrapper = wrap_response(fn, schema) record_schemas(fn, wrapper, location, response_schema=sort_schema(schema)) return wrapper
def test_sort_schema_simple(self): d = {'5': '5', '1': '1', '3': '3'} l = [5, 1, 3] srtd = util.sort_schema({ 'foo': { 'b': [d], 'a': [l] } }) # check we sort nested dicts self.assertEqual(['a','b'], list(srtd['foo'])) # check we sort dicts nested in lists self.assertEqual(['1','3','5'], list(srtd['foo']['b'][0])) # ensure we preserve the order of lists self.assertEqual([5, 1, 3], list(srtd['foo']['a'][0]))
def django_form(self, form): self._form = form schema = get_form_schema(form) self.request_schema = sort_schema(schema)
def params_schema(self, schema): if schema is not None: _validation.validate_schema(schema) self._params_schema = sort_schema(schema) self._params_schema_location = get_callsite_location()
def response_schema(self, schema): if schema is not None: _validation.validate_schema(schema) self._response_schema = sort_schema(schema) # this location is the last item in the dict, sadly self._response_schema_location = get_callsite_location()