Skip to content

Instantly share code, notes, and snippets.

@chemelnucfin
Created February 6, 2018 01:53
Show Gist options
  • Save chemelnucfin/0f709714d8426f57dec1cc481c46d62e to your computer and use it in GitHub Desktop.
Save chemelnucfin/0f709714d8426f57dec1cc481c46d62e to your computer and use it in GitHub Desktop.
=================================== FAILURES ===================================
______________________________ test_create_update ______________________________
Traceback (most recent call last):
File "~/projects/google-cloud-python/firestore/tests/system.py", line 140, in test_create_update
assert snapshot2.to_dict() == expected
AssertionError: assert {'address': {'city': 'LA'}} == {'address': {'c..., 'name': 'Sam'}
Differing items:
{'address': {'city': 'LA'}} != {'address': {'city': 'LA', 'state': 'CA'}}
Right contains more items:
{'name': 'Sam'}
Full diff:
- {u'address': {u'city': 'LA'}}
+ {'address': {'city': 'LA', 'state': 'CA'}, 'name': 'Sam'}
----------------------------- Captured stdout call -----------------------------
{u'name': 'Sam', u'address': {u'city': 'LA'}}
{u'address': {u'city': 'LA'}}
False
False
def test_create_update(client, cleanup):
document_id = 'for-set' + unique_resource_id('-')
document_id_2 = 'for-set' + unique_resource_id('-')
document = client.document('i-did-it', document_id)
document2 = client.document('i-did-it-2', document_id_2)
cleanup(document)
before = {'name': 'Sam',
'address': {'city': 'SF',
'state': 'CA'}
}
with pytest.raises(NotFound):
snapshot = document.get()
with pytest.raises(NotFound):
snapshot2 = document2.get()
document.create(before)
with pytest.raises(NotFound):
snapshot2 = document2.get()
after = {'address': {'city': 'LA'}}
option = client.write_option(create_if_missing=True)
cleanup(document2)
assert document != document2
write_result = document.update(after, option=option)
write_result2 = document2.update(after, option=option)
snapshot = document.get()
snapshot2 = document2.get()
print(snapshot.to_dict())
print(snapshot2.to_dict())
expected = {'name': 'Sam',
'address': {'city': 'LA',
'state': 'CA'}
}
print(snapshot.to_dict() == expected)
print(snapshot2.to_dict() == expected)
assert snapshot2.to_dict() == expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment