Fixed bug with nested resources
diff --git a/tests/data/zoo.json b/tests/data/zoo.json
index 50b2e55..f83e9dd 100644
--- a/tests/data/zoo.json
+++ b/tests/data/zoo.json
@@ -5,6 +5,25 @@
"restBasePath": "/zoo",
"rpcPath": "/rpc",
"resources": {
+ "my": {
+ "resources": {
+ "favorites": {
+ "methods": {
+ "list": {
+ "restPath": "favorites/@me/mine",
+ "rpcMethod": "zoo.animals.mine",
+ "httpMethod": "GET",
+ "parameters": {
+ "max-results": {
+ "restParameterType": "query",
+ "required": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"animals": {
"methods": {
"crossbreed": {
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index 44dbd6a..0c64a09 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -104,6 +104,15 @@
self.assertEqual(q['name'], ['bat'])
self.assertEqual(q['projection'], ['size'])
+ def test_nested_resources(self):
+ self.http = HttpMock('zoo.json', {'status': '200'})
+ zoo = build('zoo', 'v1', self.http)
+ self.assertTrue(getattr(zoo, 'animals'))
+ request = zoo.my().favorites().list(max_results="5")
+ parsed = urlparse.urlparse(request.uri)
+ q = parse_qs(parsed[4])
+ self.assertEqual(q['max-results'], ['5'])
+
class Next(unittest.TestCase):
diff --git a/tests/test_json_model.py b/tests/test_json_model.py
index c9c9b7d..084e0a9 100644
--- a/tests/test_json_model.py
+++ b/tests/test_json_model.py
@@ -21,7 +21,8 @@
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-from apiclient.discovery import JsonModel, HttpError
+from apiclient.model import JsonModel
+from apiclient.errors import HttpError
import os
import unittest
import httplib2
diff --git a/tests/test_mocks.py b/tests/test_mocks.py
index 91450ee..ee8ef26 100644
--- a/tests/test_mocks.py
+++ b/tests/test_mocks.py
@@ -21,7 +21,7 @@
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-from apiclient.discovery import HttpError
+from apiclient.errors import HttpError
from apiclient.discovery import build
from apiclient.http import RequestMockBuilder
from tests.util import HttpMock