Added tests to verify that different base URLs can be plugged in. See http://codereview.appspot.com/4826057/ for the code review.
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index ba0710d..3070c60 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -32,7 +32,7 @@
except ImportError:
from cgi import parse_qs
-from apiclient.discovery import build, key2param
+from apiclient.discovery import build, build_from_document, key2param
from apiclient.http import HttpMock
from apiclient.http import tunnel_patch
from apiclient.http import HttpMockSequence
@@ -65,6 +65,20 @@
pass
+class DiscoveryFromDocument(unittest.TestCase):
+ def test_can_build_from_local_document(self):
+ discovery = file(datafile('buzz.json')).read()
+ buzz = build_from_document(discovery, base="https://www.googleapis.com/")
+ self.assertTrue(buzz is not None)
+
+ def test_building_with_base_remembers_base(self):
+ discovery = file(datafile('buzz.json')).read()
+
+ base = "https://www.example.com/"
+ buzz = build_from_document(discovery, base=base)
+ self.assertEquals(base + "buzz/v1/", buzz._baseUrl)
+
+
class Discovery(unittest.TestCase):
def test_method_error_checking(self):