Consolidate handling of scopes.
Reviewed in https://codereview.appspot.com/6853060/.
diff --git a/tests/test_oauth2client_appengine.py b/tests/test_oauth2client_appengine.py
index 6039a0d..827a31f 100644
--- a/tests/test_oauth2client_appengine.py
+++ b/tests/test_oauth2client_appengine.py
@@ -175,7 +175,9 @@
apiproxy_stub_map.apiproxy.RegisterStub(
'memcache', memcache_stub.MemcacheServiceStub())
- scope = ["http://www.googleapis.com/scope"]
+ scope = [
+ "http://www.googleapis.com/scope",
+ "http://www.googleapis.com/scope2"]
credentials = AppAssertionCredentials(scope)
http = httplib2.Http()
credentials.refresh(http)
@@ -183,8 +185,18 @@
json = credentials.to_json()
credentials = Credentials.new_from_json(json)
- self.assertEqual(scope[0], credentials.scope)
+ self.assertEqual(
+ 'http://www.googleapis.com/scope http://www.googleapis.com/scope2',
+ credentials.scope)
+ scope = "http://www.googleapis.com/scope http://www.googleapis.com/scope2"
+ credentials = AppAssertionCredentials(scope)
+ http = httplib2.Http()
+ credentials.refresh(http)
+ self.assertEqual('a_token_123', credentials.access_token)
+ self.assertEqual(
+ 'http://www.googleapis.com/scope http://www.googleapis.com/scope2',
+ credentials.scope)
class TestFlowModel(db.Model):
flow = FlowProperty()
diff --git a/tests/test_oauth2client_util.py b/tests/test_oauth2client_util.py
new file mode 100644
index 0000000..6c72521
--- /dev/null
+++ b/tests/test_oauth2client_util.py
@@ -0,0 +1,27 @@
+"""Unit tests for oauth2client.util."""
+
+__author__ = 'jcgregorio@google.com (Joe Gregorio)'
+
+import unittest
+
+from oauth2client import util
+
+
+class ScopeToStringTests(unittest.TestCase):
+
+ def test_iterables(self):
+ cases = [
+ ('', ''),
+ ('', ()),
+ ('', []),
+ ('', ('', )),
+ ('', ['', ]),
+ ('a', ('a', )),
+ ('b', ['b', ]),
+ ('a b', ['a', 'b']),
+ ('a b', ('a', 'b')),
+ ('a b', 'a b'),
+ ('a b', (s for s in ['a', 'b'])),
+ ]
+ for expected, case in cases:
+ self.assertEqual(expected, util.scopes_to_string(case))