Skip to content

Commit

Permalink
Chixen bonez
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Jan 14, 2015
1 parent 6b3b0e3 commit 0ae7e34
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions gcloud/datastore/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,29 @@ def _callFUT(self, keys):
from gcloud.datastore.api import _get_dataset_id_from_keys
return _get_dataset_id_from_keys(keys)

def _make_key(self, dataset_id):

class _Key(object):
def __init__(self, dataset_id):
self.dataset_id = dataset_id

return _Key(dataset_id)

def test_empty(self):
self.assertRaises(IndexError, self._callFUT, [])

def test_w_None(self):
self.assertRaises(ValueError, self._callFUT, [None])

def test_w_mismatch(self):
foo = _Key('foo')
bar = _Key('bar')
self.assertRaises(ValueError, self._callFUT, [foo, bar])
key1 = self._make_key('foo')
key2 = self._make_key('bar')
self.assertRaises(ValueError, self._callFUT, [key1, key2])

def test_w_match(self):
foo1 = _Key('foo')
foo2 = _Key('foo')
self.assertEqual(self._callFUT([foo1, foo2]), 'foo')
key1 = self._make_key('foo')
key2 = self._make_key('foo')
self.assertEqual(self._callFUT([key1, key2]), 'foo')


class Test_get_function(unittest2.TestCase):
Expand Down Expand Up @@ -575,8 +583,3 @@ def test_with_already_completed_key(self):
COMPLETE_KEY = Key('KIND', 1234)
self.assertRaises(ValueError, self._callFUT,
COMPLETE_KEY, 2)


class _Key(object):
def __init__(self, dataset_id):
self.dataset_id = dataset_id

0 comments on commit 0ae7e34

Please sign in to comment.