Package: mock-firestore
Python Mock FirestoreAn in-memory implementation of thePython client libraryfor Google Cloud Firestore, intended for use in tests to replace the real thing. This project is in early stages and is only a partial implementation of the real  client library.To install:pip install mock-firestorePython 3.6+ is required for it to work.Usagedb=firestore.Client()mock_db=MockFirestore()# Can be used in the same way as a firestore.Client() object would be, e.g.:db.collection('users').get()mock_db.collection('users').get()To reset the store to an empty state, use thereset()method:mock_db=MockFirestore()mock_db.reset()Supported operationsmock_db=MockFirestore()# Collectionsmock_db.collections()mock_db.collection('users')mock_db.collection('users').get()mock_db.collection('users').list_documents()mock_db.collection('users').stream()# Documentsmock_db.collection('users').document()mock_db.collection('users').document('alovelace')mock_db.collection('users').document('alovelace').idmock_db.collection('users').document('alovelace').parentmock_db.collection('users').document('alovelace').update_timemock_db.collection('users').document('alovelace').read_timemock_db.collection('users').document('alovelace').get()mock_db.collection('users').document('alovelace').get().existsmock_db.collection('users').document('alovelace').get().to_dict()mock_db.collection('users').document('alovelace').set({'first':'Ada','last':'Lovelace'})mock_db.collection('users').document('alovelace').set({'first':'Augusta Ada'},merge=True)mock_db.collection('users').document('alovelace').update({'born':1815})mock_db.collection('users').document('alovelace').update({'favourite.color':'red'})mock_db.collection('users').document('alovelace').update({'associates':['Charles Babbage','Michael Faraday']})mock_db.collection('users').document('alovelace').collection('friends')mock_db.collection('users').document('alovelace').delete()mock_db.collection('users').document(document_id:'alovelace').delete()mock_db.collection('users').add({'first':'Ada','last':'Lovelace'},'alovelace')mock_db.get_all([mock_db.collection('users').document('alovelace')])mock_db.document('users/alovelace')mock_db.document('users/alovelace').update({'born':1815})mock_db.collection('users/alovelace/friends')# Queryingmock_db.collection('users').order_by('born').get()mock_db.collection('users').order_by('born',direction='DESCENDING').get()mock_db.collection('users').limit(5).get()mock_db.collection('users').where('born','==',1815).get()mock_db.collection('users').where('born','!=',1815).get()mock_db.collection('users').where('born','<',1815).get()mock_db.collection('users').where('born','>',1815).get()mock_db.collection('users').where('born','<=',1815).get()mock_db.collection('users').where('born','>=',1815).get()mock_db.collection('users').where('born','in',[1815,1900]).stream()mock_db.collection('users').where('born','in',[1815,1900]).stream()mock_db.collection('users').where('associates','array_contains','Charles Babbage').stream()mock_db.collection('users').where('associates','array_contains_any',['Charles Babbage','Michael Faraday']).stream()# Transformsmock_db.collection('users').document('alovelace').update({'likes':firestore.Increment(1)})mock_db.collection('users').document('alovelace').update({'associates':firestore.ArrayUnion(['Andrew Cross','Charles Wheatstone'])})mock_db.collection('users').document('alovelace').update({firestore.DELETE_FIELD:"born"})mock_db.collection('users').document('alovelace').update({'associates':firestore.ArrayRemove(['Andrew Cross'])})# Cursorsmock_db.collection('users').start_after({'id':'alovelace'}).stream()mock_db.collection('users').end_before({'id':'alovelace'}).stream()mock_db.collection('users').end_at({'id':'alovelace'}).stream()mock_db.collection('users').start_after(mock_db.collection('users').document('alovelace')).stream()# Transactionstransaction=mock_db.transaction()transaction.idtransaction.in_progresstransaction.get(mock_db.collection('users').where('born','==',1815))transaction.get(mock_db.collection('users').document('alovelace'))transaction.get_all([mock_db.collection('users').document('alovelace')])transaction.set(mock_db.collection('users').document('alovelace'),{'born':1815})transaction.update(mock_db.collection('users').document('alovelace'),{'born':1815})transaction.delete(mock_db.collection('users').document('alovelace'))transaction.commit()Running the testsCreate and activate a virtualenv with a Python version of at least 3.6Install dependencies withpip install -r requirements-dev-minimal.txtRun tests withpython -m unittest discover tests -t /ContributorsMatt DowdsChris TippettAnton MelnikovBen RigglemanSteve Atwellahti123Billcountry MwanikiLucas MouraKamil RomaszkoAnna MelnikovCarl ChipperfieldAaron LooKristof KrennBen PhillipsRene DelgadoklandersonWilliam LiUgo MarchandBryce Thornton