Skip to content

Commit 3884f70

Browse files
authored
Temporarily removing the get_if_changed() method from db public API (#67)
* Temporarily removing the get_if_changed() method from db public API. This method is affected by a bug in the REST API, and the RTDB team is currently working on a fix. Will add the method back, once the fix is live. * Fixing docstring indentation
1 parent d6f399e commit 3884f70

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

firebase_admin/db.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def get(self, etag=False):
134134
135135
Returns:
136136
object: If etag is False returns the decoded JSON value of the current database location.
137-
If etag is True, returns a 2-tuple consisting of the decoded JSON value and the Etag
138-
associated with the current database location.
137+
If etag is True, returns a 2-tuple consisting of the decoded JSON value and the Etag
138+
associated with the current database location.
139139
140140
Raises:
141141
ApiCallError: If an error occurs while communicating with the remote database server.
@@ -147,7 +147,7 @@ def get(self, etag=False):
147147
else:
148148
return self._client.body('get', self._add_suffix())
149149

150-
def get_if_changed(self, etag):
150+
def _get_if_changed(self, etag):
151151
"""Gets data in this location only if the specified ETag does not match.
152152
153153
Args:
@@ -193,17 +193,17 @@ def set(self, value):
193193
def set_if_unchanged(self, expected_etag, value):
194194
"""Conditonally sets the data at this location to the given value.
195195
196-
Sets the data at this location to the given value, only if expected_etag is same as the
196+
Sets the data at this location to the given value only if ``expected_etag`` is same as the
197197
ETag value in the database.
198198
199199
Args:
200200
expected_etag: Value of ETag we want to check.
201201
value: JSON-serializable value to be set at this location.
202202
203203
Returns:
204-
object: A 3-tuple consisting of a boolean, a decoded JSON value and an ETag. The boolean
205-
indicates whether the set operation was successful or not. The decoded JSON and the
206-
ETag corresponds to the latest value in this database location.
204+
tuple: A 3-tuple consisting of a boolean, a decoded JSON value and an ETag. The boolean
205+
indicates whether the set operation was successful or not. The decoded JSON and the
206+
ETag corresponds to the latest value in this database location.
207207
208208
Raises:
209209
ValueError: If the value is None, or if expected_etag is not a string.
@@ -291,18 +291,18 @@ def transaction(self, transaction_update):
291291
returning a value.
292292
293293
Args:
294-
transaction_update: A function which will be passed the current data stored at this
295-
location. The function should return the new value it would like written. If
296-
an exception is raised, the transaction will be aborted, and the data at this
297-
location will not be modified. The exceptions raised by this function are
298-
propagated to the caller of the transaction method.
294+
transaction_update: A function which will be passed the current data stored at this
295+
location. The function should return the new value it would like written. If
296+
an exception is raised, the transaction will be aborted, and the data at this
297+
location will not be modified. The exceptions raised by this function are
298+
propagated to the caller of the transaction method.
299299
300300
Returns:
301-
object: New value of the current database Reference (only if the transaction commits).
301+
object: New value of the current database Reference (only if the transaction commits).
302302
303303
Raises:
304-
TransactionError: If the transaction aborts after exhausting all retry attempts.
305-
ValueError: If transaction_update is not a function.
304+
TransactionError: If the transaction aborts after exhausting all retry attempts.
305+
ValueError: If transaction_update is not a function.
306306
"""
307307
if not callable(transaction_update):
308308
raise ValueError('transaction_update must be a function.')

integration/test_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_get_value_and_etag(self, testref, testdata):
9090
assert isinstance(etag, six.string_types)
9191

9292
def test_get_if_changed(self, testref, testdata):
93-
success, data, etag = testref.get_if_changed('wrong_etag')
93+
success, data, etag = testref._get_if_changed('wrong_etag')
9494
assert success is True
9595
assert data == testdata
9696
assert isinstance(etag, six.string_types)

tests/test_db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ def test_get_if_changed(self, data):
160160
ref = db.reference('/test')
161161
recorder = self.instrument(ref, json.dumps(data))
162162

163-
assert ref.get_if_changed('invalid-etag') == (True, data, MockAdapter.ETAG)
163+
assert ref._get_if_changed('invalid-etag') == (True, data, MockAdapter.ETAG)
164164
assert len(recorder) == 1
165165
assert recorder[0].method == 'GET'
166166
assert recorder[0].url == 'https://test.firebaseio.com/test.json'
167167
assert recorder[0].headers['if-none-match'] == 'invalid-etag'
168168

169-
assert ref.get_if_changed(MockAdapter.ETAG) == (False, None, None)
169+
assert ref._get_if_changed(MockAdapter.ETAG) == (False, None, None)
170170
assert len(recorder) == 2
171171
assert recorder[1].method == 'GET'
172172
assert recorder[1].url == 'https://test.firebaseio.com/test.json'
@@ -176,7 +176,7 @@ def test_get_if_changed(self, data):
176176
def test_get_if_changed_invalid_etag(self, etag):
177177
ref = db.reference('/test')
178178
with pytest.raises(ValueError):
179-
ref.get_if_changed(etag)
179+
ref._get_if_changed(etag)
180180

181181
@pytest.mark.parametrize('data', valid_values)
182182
def test_order_by_query(self, data):

0 commit comments

Comments
 (0)