From 132179528dd282c13dda8e6848def6a3d4be89f5 Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Tue, 22 Feb 2011 15:37:38 -0500 Subject: [PATCH] Add passthrough for query parameters that the stack uses but that don't appear in discovery. --- apiclient/discovery.py | 3 ++- tests/test_discovery.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apiclient/discovery.py b/apiclient/discovery.py index 7ae6a8a..db4dd47 100644 --- a/apiclient/discovery.py +++ b/apiclient/discovery.py @@ -44,6 +44,7 @@ VARNAME = re.compile('[a-zA-Z0-9_-]+') DISCOVERY_URI = ('https://www.googleapis.com/discovery/v0.3/describe/' '{api}/{apiVersion}') DEFAULT_METHOD_DOC = 'A description of how to use this function' +STACK_QUERY_PARAMETERS = ['trace'] def key2param(key): @@ -259,7 +260,7 @@ def createResource(http, baseUrl, model, requestBuilder, def method(self, **kwargs): for name in kwargs.iterkeys(): - if name not in argmap: + if name not in argmap and name not in STACK_QUERY_PARAMETERS: raise TypeError('Got an unexpected keyword argument "%s"' % name) for name in required_params: diff --git a/tests/test_discovery.py b/tests/test_discovery.py index adc5eb1..6a48d0e 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -103,6 +103,11 @@ class Discovery(unittest.TestCase): request = zoo.query(q="foo", i="1", n="1", b="", a=[1,2,3], o={'a':1}, e='bar') self._check_query_types(request) + def test_optional_stack_query_parameters(self): + self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) + zoo = build('zoo', 'v1', self.http) + request = zoo.query(trace='html') + def test_buzz_resources(self): self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) buzz = build('buzz', 'v1', self.http)