@@ -46,20 +46,6 @@ def test_path_is_abstract(self):
4646 mixin = self ._makeOne ()
4747 self .assertRaises (NotImplementedError , lambda : mixin .path )
4848
49- def test_batch (self ):
50- connection = _Connection ({'foo' : 'Qux' , 'bar' : 'Baz' })
51- derived = self ._derivedClass (connection , '/path' )()
52- with derived .batch :
53- derived ._patch_properties ({'foo' : 'Foo' })
54- derived ._patch_properties ({'bar' : 'Baz' })
55- derived ._patch_properties ({'foo' : 'Qux' })
56- kw = connection ._requested
57- self .assertEqual (len (kw ), 1 )
58- self .assertEqual (kw [0 ]['method' ], 'PATCH' )
59- self .assertEqual (kw [0 ]['path' ], '/path' )
60- self .assertEqual (kw [0 ]['data' ], {'foo' : 'Qux' , 'bar' : 'Baz' })
61- self .assertEqual (kw [0 ]['query_params' ], {'projection' : 'full' })
62-
6349 def test_reload (self ):
6450 connection = _Connection ({'foo' : 'Foo' })
6551 derived = self ._derivedClass (connection , '/path' )()
@@ -84,75 +70,6 @@ def test__patch_properties(self):
8470 self .assertEqual (kw [0 ]['query_params' ], {'projection' : 'full' })
8571
8672
87- class Test_PropertyBatch (unittest2 .TestCase ):
88-
89- def _getTargetClass (self ):
90- from gcloud .storage ._helpers import _PropertyBatch
91- return _PropertyBatch
92-
93- def _makeOne (self , wrapped ):
94- return self ._getTargetClass ()(wrapped )
95-
96- def _makeWrapped (self , connection = None , path = None ):
97- from gcloud .storage ._helpers import _PropertyMixin
98-
99- class Wrapped (_PropertyMixin ):
100-
101- @property
102- def connection (self ):
103- return connection
104-
105- @property
106- def path (self ):
107- return path
108-
109- return Wrapped ()
110-
111- def test_ctor_does_not_intercept__patch_properties (self ):
112- wrapped = self ._makeWrapped ()
113- before = wrapped ._patch_properties
114- batch = self ._makeOne (wrapped )
115- after = wrapped ._patch_properties
116- self .assertEqual (before , after )
117- self .assertTrue (batch ._wrapped is wrapped )
118-
119- def test___exit___w_error_skips_patch (self ):
120- class Testing (Exception ):
121- pass
122- connection = _Connection ()
123- wrapped = self ._makeWrapped (connection )
124- batch = self ._makeOne (wrapped )
125- try :
126- with batch :
127- # deferred patching
128- wrapped ._patch_properties ({'foo' : 'Foo' })
129- # but error -> no call to the real '_patch_properties'
130- raise Testing ('testing' )
131- except Testing :
132- pass
133-
134- kw = connection ._requested
135- self .assertEqual (len (kw ), 0 )
136-
137- def test___exit___no_error_calls_patch (self ):
138- connection = _Connection ({'foo' : 'Foo' })
139- wrapped = self ._makeWrapped (connection , '/path' )
140- batch = self ._makeOne (wrapped )
141- kw = connection ._requested
142- with batch :
143- # deferred patching
144- wrapped ._patch_properties ({'foo' : 'Foo' })
145- wrapped ._patch_properties ({'bar' : 'Baz' })
146- wrapped ._patch_properties ({'foo' : 'Qux' })
147- self .assertEqual (len (kw ), 0 )
148- # exited w/o error -> call to the real '_patch_properties'
149- self .assertEqual (len (kw ), 1 )
150- self .assertEqual (kw [0 ]['method' ], 'PATCH' )
151- self .assertEqual (kw [0 ]['path' ], '/path' )
152- self .assertEqual (kw [0 ]['data' ], {'foo' : 'Qux' , 'bar' : 'Baz' })
153- self .assertEqual (kw [0 ]['query_params' ], {'projection' : 'full' })
154-
155-
15673class Test__scalar_property (unittest2 .TestCase ):
15774
15875 def _callFUT (self , fieldName ):
0 commit comments