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 2323
2424# Declaring module version as per https://www.python.org/dev/peps/pep-0396/#specification
2525# Update this accordingly for each release.
26- __version__ = '2.2.0 '
26+ __version__ = '2.2.1 '
2727
2828_apps = {}
2929_apps_lock = threading .RLock ()
Original file line number Diff line number Diff line change @@ -201,10 +201,6 @@ def update(self, value):
201201
202202 def _update_with_etag (self , value , etag ):
203203 """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.' )
208204 if not isinstance (etag , six .string_types ):
209205 raise ValueError ('ETag must be a string.' )
210206
Original file line number Diff line number Diff line change @@ -178,6 +178,15 @@ def transaction_update(snapshot):
178178 assert new_value == expected
179179 assert ref .get () == expected
180180
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+
181190 def test_delete (self , testref ):
182191 python = testref .parent
183192 ref = python .child ('users' ).push ('foo' )
Original file line number Diff line number Diff line change @@ -318,6 +318,18 @@ def transaction_update(data):
318318 assert recorder [1 ].method == 'PUT'
319319 assert json .loads (recorder [1 ].body .decode ()) == {'foo1' : 'bar1' , 'foo2' : 'bar2' }
320320
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+
321333 def test_transaction_error (self ):
322334 ref = db .reference ('/test' )
323335 data = {'foo1' : 'bar1' }
You can’t perform that action at this time.
0 commit comments