diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41a7cd6..f6ebb19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index 40a4ba9..cf59f85 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 /` diff --git a/mockfirestore/document.py b/mockfirestore/document.py index 24aa433..6e64926 100644 --- a/mockfirestore/document.py +++ b/mockfirestore/document.py @@ -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 @@ -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: @@ -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: @@ -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)) @@ -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)) diff --git a/setup.py b/setup.py index f55cb88..0fa1489 100644 --- a/setup.py +++ b/setup.py @@ -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", ], -) \ No newline at end of file +)