Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
python-version: [ '3.11', '3.12', '3.13' ]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To install:

`pip install mock-firestore`

Python 3.6+ is required for it to work.
Python 3.7+ is required for it to work.

## Usage

Expand Down Expand Up @@ -105,7 +105,7 @@ transaction.commit()
```

## Running the tests
* Create and activate a virtualenv with a Python version of at least 3.6
* Create and activate a virtualenv with a Python version of at least 3.7
* Install dependencies with `pip install -r requirements-dev-minimal.txt`
* Run tests with `python -m unittest discover tests -t /`

Expand Down
16 changes: 8 additions & 8 deletions mockfirestore/document.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import deepcopy
from functools import reduce
import operator
from typing import List, Dict, Any
from typing import List, Dict, Any, Union
from mockfirestore import NotFound
from mockfirestore._helpers import (
Timestamp, Document, Store, get_by_path, set_by_path, delete_by_path
Expand All @@ -22,8 +22,8 @@ def id(self):
def exists(self) -> bool:
return self._doc != {}

def to_dict(self) -> Document:
return self._doc
def to_dict(self) -> Union[Dict[str, Any], None]:
return self._doc if self.exists else None

@property
def create_time(self) -> Timestamp:
Expand All @@ -39,7 +39,7 @@ def read_time(self) -> Timestamp:
timestamp = Timestamp.from_now()
return timestamp

def get(self, field_path: str) -> Any:
def get(self, field_path: str, timeout: float = None) -> Any:
if not self.exists:
return None
else:
Expand All @@ -63,13 +63,13 @@ def __init__(self, data: Store, path: List[str],
def id(self):
return self._path[-1]

def get(self) -> DocumentSnapshot:
def get(self, timeout: float=None) -> DocumentSnapshot:
return DocumentSnapshot(self, get_by_path(self._data, self._path))

def delete(self):
def delete(self, timeout: float=None):
delete_by_path(self._data, self._path)

def set(self, data: Dict, merge=False):
def set(self, data: Dict, merge=False, timeout: float=None):
if merge:
try:
self.update(deepcopy(data))
Expand All @@ -78,7 +78,7 @@ def set(self, data: Dict, merge=False):
else:
set_by_path(self._data, self._path, deepcopy(data))

def update(self, data: Dict[str, Any]):
def update(self, data: Dict[str, Any], timeout: float=None):
document = get_by_path(self._data, self._path)
if document == {}:
raise NotFound('No document to update: {}'.format(self._path))
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
packages=setuptools.find_packages(),
test_suite='',
classifiers=[
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
"License :: OSI Approved :: MIT License",
],
)
)
Loading