File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 23
23
24
24
# Declaring module version as per https://www.python.org/dev/peps/pep-0396/#specification
25
25
# Update this accordingly for each release.
26
- __version__ = '2.2.0 '
26
+ __version__ = '2.2.1 '
27
27
28
28
_apps = {}
29
29
_apps_lock = threading .RLock ()
Original file line number Diff line number Diff line change @@ -201,10 +201,6 @@ def update(self, value):
201
201
202
202
def _update_with_etag (self , value , etag ):
203
203
"""Sets the data at this location to the specified value, if the etag matches."""
204
- if not value or not isinstance (value , dict ):
205
- raise ValueError ('Value argument must be a non-empty dictionary.' )
206
- if None in value .keys () or None in value .values ():
207
- raise ValueError ('Dictionary must not contain None keys or values.' )
208
204
if not isinstance (etag , six .string_types ):
209
205
raise ValueError ('ETag must be a string.' )
210
206
Original file line number Diff line number Diff line change @@ -178,6 +178,15 @@ def transaction_update(snapshot):
178
178
assert new_value == expected
179
179
assert ref .get () == expected
180
180
181
+ def test_transaction_scalar (self , testref ):
182
+ python = testref .parent
183
+ ref = python .child ('users/count' )
184
+ ref .set (42 )
185
+ new_value = ref .transaction (lambda x : x + 1 if x else 1 )
186
+ expected = 43
187
+ assert new_value == expected
188
+ assert ref .get () == expected
189
+
181
190
def test_delete (self , testref ):
182
191
python = testref .parent
183
192
ref = python .child ('users' ).push ('foo' )
Original file line number Diff line number Diff line change @@ -318,6 +318,18 @@ def transaction_update(data):
318
318
assert recorder [1 ].method == 'PUT'
319
319
assert json .loads (recorder [1 ].body .decode ()) == {'foo1' : 'bar1' , 'foo2' : 'bar2' }
320
320
321
+ def test_transaction_scalar (self ):
322
+ ref = db .reference ('/test/count' )
323
+ data = 42
324
+ recorder = self .instrument (ref , json .dumps (data ))
325
+
326
+ new_value = ref .transaction (lambda x : x + 1 if x else 1 )
327
+ assert new_value == 43
328
+ assert len (recorder ) == 2
329
+ assert recorder [0 ].method == 'GET'
330
+ assert recorder [1 ].method == 'PUT'
331
+ assert json .loads (recorder [1 ].body .decode ()) == 43
332
+
321
333
def test_transaction_error (self ):
322
334
ref = db .reference ('/test' )
323
335
data = {'foo1' : 'bar1' }
You can’t perform that action at this time.
0 commit comments