Skip to content

Commit

Permalink
Attempt to reproduce issue #5489.
Browse files Browse the repository at this point in the history
The new system tests both pass.
  • Loading branch information
tseaver committed Sep 6, 2018
1 parent 9de4dc4 commit c1da96e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions firestore/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,47 @@ def test_document_set_merge(client, cleanup):
assert snapshot2.update_time == write_result2.update_time


def test_document_set_w_int_field(client, cleanup):
document_id = 'set-int-key' + unique_resource_id('-')
document = client.document('i-did-it', document_id)
# Add to clean-up before API request (in case ``set()`` fails).
cleanup(document)

# 0. Make sure the document doesn't exist yet
snapshot = document.get()
assert not snapshot.exists

# 1. Use ``create()`` to create the document.
before = {'testing': '1'}
write_result1 = document.create(before)
data = {'14': {'status': 'active'}}
write_result2 = document.set(data)
snapshot1 = document.get()
assert snapshot1.to_dict() == data


def test_document_update_w_int_field(client, cleanup):
# Attempt to reproduce #5489.
document_id = 'update-int-key' + unique_resource_id('-')
document = client.document('i-did-it', document_id)
# Add to clean-up before API request (in case ``set()`` fails).
cleanup(document)

# 0. Make sure the document doesn't exist yet
snapshot = document.get()
assert not snapshot.exists

# 1. Use ``create()`` to create the document.
before = {'testing': '1'}
write_result1 = document.create(before)
data = {'14': {'status': 'active'}}
write_result2 = document.update(data)
snapshot1 = document.get()
expected = before.copy()
expected.update(data)
assert snapshot1.to_dict() == expected


def test_update_document(client, cleanup):
document_id = 'for-update' + unique_resource_id('-')
document = client.document('made', document_id)
Expand Down

0 comments on commit c1da96e

Please sign in to comment.