Merge changes
This commit is contained in:
@@ -424,10 +424,19 @@ def createResource(http, baseUrl, model, requestBuilder,
|
|||||||
|
|
||||||
for name, enums in enum_params.iteritems():
|
for name, enums in enum_params.iteritems():
|
||||||
if name in kwargs:
|
if name in kwargs:
|
||||||
if kwargs[name] not in enums:
|
# We need to handle the case of a repeated enum
|
||||||
raise TypeError(
|
# name differently, since we want to handle both
|
||||||
'Parameter "%s" value "%s" is not an allowed value in "%s"' %
|
# arg='value' and arg=['value1', 'value2']
|
||||||
(name, kwargs[name], str(enums)))
|
if (name in repeated_params and
|
||||||
|
not isinstance(kwargs[name], basestring)):
|
||||||
|
values = kwargs[name]
|
||||||
|
else:
|
||||||
|
values = [kwargs[name]]
|
||||||
|
for value in values:
|
||||||
|
if value not in enums:
|
||||||
|
raise TypeError(
|
||||||
|
'Parameter "%s" value "%s" is not an allowed value in "%s"' %
|
||||||
|
(name, value, str(enums)))
|
||||||
|
|
||||||
actual_query_params = {}
|
actual_query_params = {}
|
||||||
actual_path_params = {}
|
actual_path_params = {}
|
||||||
|
|||||||
@@ -178,6 +178,17 @@
|
|||||||
"bar"
|
"bar"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"er": {
|
||||||
|
"type": "string",
|
||||||
|
"location": "query",
|
||||||
|
"required": false,
|
||||||
|
"repeated": true,
|
||||||
|
"enum": [
|
||||||
|
"one",
|
||||||
|
"two",
|
||||||
|
"three"
|
||||||
|
]
|
||||||
|
},
|
||||||
"rr": {
|
"rr": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"location": "query",
|
"location": "query",
|
||||||
|
|||||||
@@ -170,13 +170,18 @@ class Discovery(unittest.TestCase):
|
|||||||
self._check_query_types(request)
|
self._check_query_types(request)
|
||||||
|
|
||||||
request = zoo.query(
|
request = zoo.query(
|
||||||
q="foo", i="1", n="1", b="", a=[1,2,3], o={'a':1}, e='bar')
|
q="foo", i="1", n="1", b="", a=[1,2,3], o={'a':1}, e='bar', er='two')
|
||||||
|
|
||||||
request = zoo.query(
|
request = zoo.query(
|
||||||
q="foo", i="1", n="1", b="", a=[1,2,3], o={'a':1}, e='bar', rr=['foo',
|
q="foo", i="1", n="1", b="", a=[1,2,3], o={'a':1}, e='bar',
|
||||||
'bar'])
|
er=['one', 'three'], rr=['foo', 'bar'])
|
||||||
self._check_query_types(request)
|
self._check_query_types(request)
|
||||||
|
|
||||||
|
# Five is right out.
|
||||||
|
self.assertRaisesRegexp(
|
||||||
|
TypeError, '"five" is not an allowed value in',
|
||||||
|
zoo.query, er=['one', 'five'])
|
||||||
|
|
||||||
def test_optional_stack_query_parameters(self):
|
def test_optional_stack_query_parameters(self):
|
||||||
http = HttpMock(datafile('zoo.json'), {'status': '200'})
|
http = HttpMock(datafile('zoo.json'), {'status': '200'})
|
||||||
zoo = build('zoo', 'v1', http)
|
zoo = build('zoo', 'v1', http)
|
||||||
|
|||||||
Reference in New Issue
Block a user