Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Review comments (commit will be squashed)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Feb 20, 2016
1 parent a5a9c83 commit 2789e3e
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions tests/contrib/test_multistore_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os
import stat
import tempfile
import unittest
import unittest2

from oauth2client import util
from oauth2client.client import OAuth2Credentials
Expand Down Expand Up @@ -48,25 +48,31 @@ def filename(self):
return self.filename_str


class Test__dict_to_tuple_key(unittest.TestCase):
class Test__dict_to_tuple_key(unittest2.TestCase):

def test_key_conversions(self):
d = {'somekey': 'some value', 'another': 'something else',
'onemore': 'foo'}
tuple_key = multistore_file._dict_to_tuple_key(d)
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
self.assertEqual(
(('another', 'something else'),
('onemore', 'foo'),
('somekey', 'some value')),
tuple_key)

expected_output = (
(key2, val2),
(key3, val3),
(key1, val1),
)
self.assertTupleEqual(expected_output, tuple_key)
# check we get the original dictionary back
self.assertEqual(d, dict(tuple_key))
self.assertDictEqual(test_dict, dict(tuple_key))


class MultistoreFileTests(unittest.TestCase):
class MultistoreFileTests(unittest2.TestCase):

def tearDown(self):
try:
Expand Down Expand Up @@ -275,3 +281,7 @@ def test_multistore_file_get_all_keys(self):
store2.delete()
keys = multistore_file.get_all_credential_keys(FILENAME)
self.assertEquals([], keys)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()

0 comments on commit 2789e3e

Please sign in to comment.