Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Move implicit majyk inside 'Client.__init__'.#956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,29 +18,45 @@ | ||
| class TestClient(unittest2.TestCase): | ||
| DATASET_ID = 'DATASET' | ||
| CONNECTION = object() | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| def _getTargetClass(self): | ||
| from gcloud.datastore.client import Client | ||
| return Client | ||
| def _makeOne(self, dataset_id=DATASET_ID, namespace=None, connection=None): | ||
| return self._getTargetClass()(dataset_id, namespace=namespace, | ||
| def _makeOne(self, dataset_id=DATASET_ID, namespace=None, | ||
| connection=CONNECTION): | ||
| return self._getTargetClass()(dataset_id=dataset_id, | ||
| namespace=namespace, | ||
| connection=connection) | ||
| def test_ctor_w_dataset_id_None(self): | ||
| self.assertRaises(ValueError, self._makeOne, None) | ||
| def test_ctor_w_dataset_id_no_environ(self): | ||
| self.assertRaises(EnvironmentError, self._makeOne, None) | ||
| def test_ctor_w_dataset_id_no_connection(self): | ||
| client = self._makeOne() | ||
| self.assertEqual(client.dataset_id, self.DATASET_ID) | ||
| def test_ctor_w_implicit_inputs(self): | ||
| from gcloud._testing import _Monkey | ||
| from gcloud.datastore import client as _MUT | ||
| OTHER = 'other' | ||
| conn = object() | ||
| klass = self._getTargetClass() | ||
| with _Monkey(_MUT, | ||
| _determine_default_dataset_id=lambda x: x or OTHER, | ||
| get_connection=lambda: conn): | ||
| client = klass() | ||
| self.assertEqual(client.dataset_id, OTHER) | ||
| self.assertEqual(client.namespace, None) | ||
| self.assertTrue(client.connection is conn) | ||
| def test_ctor_w_explicit_inputs(self): | ||
| OTHER = 'other' | ||
| NAMESPACE = 'namespace' | ||
| conn = object() | ||
| namespace = object() | ||
| client = self._makeOne(namespace=namespace, connection=conn) | ||
| self.assertEqual(client.dataset_id, self.DATASET_ID) | ||
| client = self._makeOne(dataset_id=OTHER, | ||
| namespace=NAMESPACE, | ||
| connection=conn) | ||
| self.assertEqual(client.dataset_id, OTHER) | ||
| self.assertEqual(client.namespace, NAMESPACE) | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| self.assertTrue(client.connection is conn) | ||
| self.assertTrue(client.namespace is namespace) | ||
| def test_get_defaults(self): | ||
| from gcloud.datastore import client as MUT | ||
| @@ -60,7 +76,7 @@ def _get(*args, **kw): | ||
| self.assertEqual(_called_with[0][0], (key,)) | ||
| self.assertTrue(_called_with[0][1]['missing'] is None) | ||
| self.assertTrue(_called_with[0][1]['deferred'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is self.CONNECTION) | ||
| self.assertEqual(_called_with[0][1]['dataset_id'], self.DATASET_ID) | ||
| def test_get_explicit(self): | ||
| @@ -103,7 +119,7 @@ def _get_multi(*args, **kw): | ||
| self.assertEqual(_called_with[0][0], ([key],)) | ||
| self.assertTrue(_called_with[0][1]['missing'] is None) | ||
| self.assertTrue(_called_with[0][1]['deferred'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is self.CONNECTION) | ||
| self.assertEqual(_called_with[0][1]['dataset_id'], self.DATASET_ID) | ||
| def test_get_multi_explicit(self): | ||
| @@ -144,7 +160,7 @@ def _put(*args, **kw): | ||
| client.put(entity) | ||
| self.assertEqual(_called_with[0][0], (entity,)) | ||
| self.assertTrue(_called_with[0][1]['connection'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is self.CONNECTION) | ||
| self.assertEqual(_called_with[0][1]['dataset_id'], self.DATASET_ID) | ||
| def test_put_w_connection(self): | ||
| @@ -182,7 +198,7 @@ def _put_multi(*args, **kw): | ||
| client.put_multi([entity]) | ||
| self.assertEqual(_called_with[0][0], ([entity],)) | ||
| self.assertTrue(_called_with[0][1]['connection'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is self.CONNECTION) | ||
| self.assertEqual(_called_with[0][1]['dataset_id'], self.DATASET_ID) | ||
| def test_put_multi_w_connection(self): | ||
| @@ -220,7 +236,7 @@ def _delete(*args, **kw): | ||
| client.delete(key) | ||
| self.assertEqual(_called_with[0][0], (key,)) | ||
| self.assertTrue(_called_with[0][1]['connection'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is self.CONNECTION) | ||
| self.assertEqual(_called_with[0][1]['dataset_id'], self.DATASET_ID) | ||
| def test_delete_w_connection(self): | ||
| @@ -257,7 +273,7 @@ def _delete_multi(*args, **kw): | ||
| client.delete_multi([key]) | ||
| self.assertEqual(_called_with[0][0], ([key],)) | ||
| self.assertTrue(_called_with[0][1]['connection'] is None) | ||
| self.assertTrue(_called_with[0][1]['connection'] is self.CONNECTION) | ||
| self.assertEqual(_called_with[0][1]['dataset_id'], self.DATASET_ID) | ||
| def test_delete_multi_w_connection(self): | ||
| @@ -351,7 +367,8 @@ def test_batch_wo_connection(self): | ||
| self.assertTrue(isinstance(batch, _Dummy)) | ||
| self.assertEqual(batch.args, ()) | ||
| self.assertEqual(batch.kwargs, | ||
| {'dataset_id': self.DATASET_ID, 'connection': None}) | ||
| {'dataset_id': self.DATASET_ID, | ||
| 'connection': self.CONNECTION}) | ||
| def test_batch_w_connection(self): | ||
| from gcloud.datastore import client as MUT | ||
| @@ -378,7 +395,8 @@ def test_transaction_wo_connection(self): | ||
| self.assertTrue(isinstance(xact, _Dummy)) | ||
| self.assertEqual(xact.args, ()) | ||
| self.assertEqual(xact.kwargs, | ||
| {'dataset_id': self.DATASET_ID, 'connection': None}) | ||
| {'dataset_id': self.DATASET_ID, | ||
| 'connection': self.CONNECTION}) | ||
| def test_transaction_w_connection(self): | ||
| from gcloud.datastore import client as MUT | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.