8000 Removed etag method. · firebase/firebase-admin-python@eb21db2 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb21db2

Browse files
committed
Removed etag method.
1 parent 6f9d71a commit eb21db2

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

firebase_admin/db.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,6 @@ def child(self, path):
125125
full_path = self._pathurl + '/' + path
126126
return Reference(client=self._client, path=full_path)
127127

128-
def etag(self):
129-
"""Returns the ETag at the current location of the database.
130-
131-
Returns:
132-
str: ETag of the current database Reference.
133-
"""
134-
headers = self._client.request('get', self._add_suffix(),
135-
headers={'X-Firebase-ETag' : 'true'},
136-
resp_headers=True,
137-
params='print=silent')
138-
return headers.get('ETag')
139-
140128
def get(self, etag=False):
141129
"""Returns the value, and possibly the ETag, at the current location of the database.
142130
@@ -180,7 +168,7 @@ def get_if_changed(self, etag):
180168
new_etag = headers.get('ETag')
181169
return True, new_etag, value
182170
elif resp.status_code == 304:
183-
return False, etag, None
171+
return False, None, None
184172

185173
def set(self, value):
186174
"""Sets the data at this location to the given value.

integration/test_db.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ def test_update_nested_children(self, testref):
150150
assert edward.get() == {'name' : 'Edward Cope', 'since' : 1840}
151151
assert jack.get() == {'name' : 'Jack Horner', 'since' : 1946}
152152

153-
def test_etag(self, testref):
154-
python = testref.parent
155-
etag = python.etag()
156-
assert isinstance(etag, six.string_types)
157-
158153
def test_get_if_changed(self, testref):
159154
python = testref.parent
160155
push_data = {'name' : 'Edward Cope', 'since' : 1800}
@@ -163,6 +158,9 @@ def test_get_if_changed(self, testref):
163158
assert changed_data[0]
164159
assert changed_data[2] == push_data
165160

161+
unchanged_data = edward.get_if_changed(changed_data[1])
162+
assert unchanged_data == (False, None, None)
163+
166164
def test_get_and_set_with_etag(self, testref):
167165
python = testref.parent
168166
push_data = {'name' : 'Edward Cope', 'since' : 1800}

tests/test_db.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ def __init__(self, data, status, recorder):
3434

3535
def send(self, request, **kwargs):
3636
if_match = request.headers.get('if-match')
37+
if_none_match = request.headers.get('if-none-match')
3738
if if_match and if_match != MockAdapter._ETAG:
3839
response = Response()
3940
response._content = request.body
4041
response.headers = {'ETag': MockAdapter._ETAG}
4142
raise exceptions.RequestException(response=response)
43+
4244
resp = super(MockAdapter, self).send(request, **kwargs)
4345
resp.headers = {'ETag': MockAdapter._ETAG}
46+
if if_none_match and if_none_match == MockAdapter._ETAG:
47+
resp.status_code = 304
4448
return resp
4549

4650

@@ -163,13 +167,10 @@ def test_get_if_changed(self, data):
163167
assert recorder[0].method == 'GET'
164168
assert recorder[0].url == 'https://test.firebaseio.com/test.json'
165169

166-
@pytest.mark.parametrize('data', valid_values)
167-
def test_etag(self, data):
168-
ref = db.reference('/test')
169-
recorder = self.instrument(ref, json.dumps(data))
170-
assert ref.etag() == '0'
170+
assert ref.get_if_changed('0') == (False, None, None)
171+
assert len(recorder) == 2
171172
assert recorder[0].method == 'GET'
172-
assert recorder[0].url == 'https://test.firebaseio.com/test.json?print=silent'
173+
assert recorder[0].url == 'https://test.firebaseio.com/test.json'
173174

174175
@pytest.mark.parametrize('data', valid_values)
175176
def test_order_by_query(self, data):

0 commit comments

Comments
 (0)
0