aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanny Hermes <daniel.j.hermes@gmail.com>2016-02-22 21:53:10 -0800
committerDanny Hermes <daniel.j.hermes@gmail.com>2016-02-22 21:53:10 -0800
commit55ed32d89096a466b99be89bf9b3efa3c08bb3bd (patch)
tree5f774860f37022a36a19310e1d68b0ec0ea4e1d6 /tests
parent349942b0db8e96c336802dc421fd4f1670e4b7e8 (diff)
parentae0d5489d1793c23e4ed24ee9848478e95866791 (diff)
downloadoauth2client-55ed32d89096a466b99be89bf9b3efa3c08bb3bd.tar.gz
Merge pull request #429 from dhermes/move-dict-to-tuple
Moving util.dict_to_tuple_key() into only module that uses it.
Diffstat (limited to 'tests')
-rw-r--r--tests/contrib/test_multistore_file.py28
-rw-r--r--tests/test_util.py18
2 files changed, 28 insertions, 18 deletions
diff --git a/tests/contrib/test_multistore_file.py b/tests/contrib/test_multistore_file.py
index 5e1d29b..11c423d 100644
--- a/tests/contrib/test_multistore_file.py
+++ b/tests/contrib/test_multistore_file.py
@@ -48,6 +48,30 @@ class _MockLockedFile(object):
return self.filename_str
+class Test__dict_to_tuple_key(unittest2.TestCase):
+
+ def test_key_conversions(self):
+ key1, val1 = 'somekey', 'some value'
+ key2, val2 = 'another', 'something else'
+ key3, val3 = 'onemore', 'foo'
+ test_dict = {
+ key1: val1,
+ key2: val2,
+ key3: val3,
+ }
+ tuple_key = multistore_file._dict_to_tuple_key(test_dict)
+
+ # the resulting key should be naturally sorted
+ expected_output = (
+ (key2, val2),
+ (key3, val3),
+ (key1, val1),
+ )
+ self.assertTupleEqual(expected_output, tuple_key)
+ # check we get the original dictionary back
+ self.assertDictEqual(test_dict, dict(tuple_key))
+
+
class MultistoreFileTests(unittest2.TestCase):
def tearDown(self):
@@ -257,3 +281,7 @@ class MultistoreFileTests(unittest2.TestCase):
store2.delete()
keys = multistore_file.get_all_credential_keys(FILENAME)
self.assertEquals([], keys)
+
+
+if __name__ == '__main__': # pragma: NO COVER
+ unittest2.main()
diff --git a/tests/test_util.py b/tests/test_util.py
index c298c82..5a808b4 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -42,23 +42,5 @@ class StringToScopeTests(unittest.TestCase):
self.assertEqual(expected, util.string_to_scopes(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))
-
-
if __name__ == '__main__': # pragma: NO COVER
unittest.main()