Files
deb-python-oauth2client/tests/test_util.py
Craig Citro a97121f0d6 Drop the googleapiclient copy, and cleanup tests.
This drops the duplication of `googleapiclient` inside the `oauth2client` repo,
which involved several steps:

* Delete the actual `googleapiclient` files.
* Remove the duplicated tests, since they're also hosted in the
  `googleapiclient` repo.
* Add a copy of three testing-related functions back in, since they're also
  used in the tests here. This was `HttpMock` and `HttpMockSequence` in
  `tests/http_mock.py`, and `assertUrisEqual` in `tests/test_oauth2client.py`.

Once that was done, I did just the tiniest bit of cleanup in the tests:

* Remove the now-superfluous `_oauth2client_` in the filenames for all the
  tests.
* Drop unneeded files from `data/`.
* Add `py26` back as a `tox` testing environment.
* Temporarily disable the `appengine` test for both environments.

In a coming PR, I'll actually clean up the GAE test to work correctly in the
presence or absence of `dev_appserver`, but this isn't a bad first step. (In
particular, my next PR will just add a `.travis.yml`.)
2014-05-05 12:09:05 -07:00

45 lines
1.0 KiB
Python

"""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))
class KeyConversionTests(unittest.TestCase):
def test_key_conversions(self):
d = {'somekey': 'some value', 'another': 'something else', 'onemore': 'foo'}
tuple_key = util.dict_to_tuple_key(d)
# the resulting key should be naturally sorted
self.assertEqual(
(('another', 'something else'),
('onemore', 'foo'),
('somekey', 'some value')),
tuple_key)
# check we get the original dictionary back
self.assertEqual(d, dict(tuple_key))