@@ -325,7 +325,7 @@ def test_set_implicit_three_env_appengine_and_compute(self):
325325 self .assertEqual (connection .timeout , None )
326326
327327
328- class Test_lazy_loaded_dataset_id (unittest2 .TestCase ):
328+ class Test_lazy_loading (unittest2 .TestCase ):
329329
330330 def setUp (self ):
331331 from gcloud .datastore ._testing import _setup_defaults
@@ -335,15 +335,6 @@ def tearDown(self):
335335 from gcloud .datastore ._testing import _tear_down_defaults
336336 _tear_down_defaults (self )
337337
338- def test_prop_default (self ):
339- from gcloud .datastore import _implicit_environ
340- from gcloud .datastore ._implicit_environ import _DefaultsContainer
341- from gcloud .datastore ._implicit_environ import _LazyProperty
342-
343- self .assertTrue (isinstance (_DefaultsContainer .dataset_id ,
344- _LazyProperty ))
345- self .assertEqual (_implicit_environ ._DEFAULTS .dataset_id , None )
346-
347338 def test_prop_on_wrong_class (self ):
348339 from gcloud .datastore ._implicit_environ import _LazyProperty
349340
@@ -357,7 +348,7 @@ class FakeEnv(object):
357348 self .assertTrue (FakeEnv .dataset_id is data_prop )
358349 self .assertTrue (FakeEnv ().dataset_id is data_prop )
359350
360- def test_prop_descriptor (self ):
351+ def test_descriptor_for_dataset_id (self ):
361352 from gcloud ._testing import _Monkey
362353 from gcloud .datastore import _implicit_environ
363354
@@ -366,17 +357,30 @@ def test_prop_descriptor(self):
366357
367358 DEFAULT = object ()
368359
369- def mock_default ():
370- return DEFAULT
371-
372360 with _Monkey (_implicit_environ ,
373- _determine_default_dataset_id = mock_default ):
361+ _determine_default_dataset_id = lambda : DEFAULT ):
374362 lazy_loaded = _implicit_environ ._DEFAULTS .dataset_id
375363
376364 self .assertEqual (lazy_loaded , DEFAULT )
377365 self .assertTrue (
378366 'dataset_id' in _implicit_environ ._DEFAULTS .__dict__ )
379367
368+ def test_descriptor_for_connection (self ):
369+ from gcloud ._testing import _Monkey
370+ from gcloud .datastore import _implicit_environ
371+
372+ self .assertFalse (
373+ 'connection' in _implicit_environ ._DEFAULTS .__dict__ )
374+
375+ DEFAULT = object ()
376+
377+ with _Monkey (_implicit_environ , get_connection = lambda : DEFAULT ):
378+ lazy_loaded = _implicit_environ ._DEFAULTS .connection
379+
380+ self .assertEqual (lazy_loaded , DEFAULT )
381+ self .assertTrue (
382+ 'connection' in _implicit_environ ._DEFAULTS .__dict__ )
383+
380384
381385class Test_get_connection (unittest2 .TestCase ):
382386
0 commit comments