Google Cloud Firestore

From XennisWiki
(Redirected from Google-cloud-firestore)
Jump to: navigation, search

Cloud Firestore is a NoSQL document database of the Google Cloud Platform.

Python SDK


pip install google-cloud-firestore

Example usage

from import firestore

db = firestore.Client()
doc_ref = db.collection('photos').document('mycar')
    'id': image_id,
    'uri': image_uri,

Unit test

from unittest import mock

mock_document = mock.MagicMock()
mock_document.set = mock.MagicMock()
mock_collection = mock.MagicMock()
mock_collection.document.return_value = mock_document
mock_firestore_client = mock.MagicMock()
mock_firestore_client.collection.return_value = mock_collection, 'document', {'some key': 'some value'})
# Check the correct collection was chosen
# Check the correct document was chosen
# Check set method is called with the correct data
mock_document.set.assert_called_once_with({'some key': 'some value'})

See also

External links