From 80a66a778a23254243401e7b358e177ba9489834 Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Sat, 13 Apr 2024 16:50:01 -0700 Subject: [PATCH 1/5] Update set python versions to those currently supported --- .github/workflows/test.yml | 2 +- README.md | 2 +- setup.py | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41a7cd6..e82071d 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.7', '3.8', '3.9', '3.10', '3.11', '3.12' ] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 40a4ba9..39033da 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 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 +) From 90bd2b38cf2d6cc89e1274e39eb621b759bcbf2c Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Sat, 13 Apr 2024 17:54:46 -0700 Subject: [PATCH 2/5] change one more occurence of 3.6 to 3.7 in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39033da..cf59f85 100644 --- a/README.md +++ b/README.md @@ -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 /` From cfdc79d9262bf200418d09d8109b3e15f7894cbb Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Wed, 15 Jan 2025 22:47:48 -0800 Subject: [PATCH 3/5] add optional timeout arg on basic DocumentReference operations --- mockfirestore/document.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mockfirestore/document.py b/mockfirestore/document.py index 24aa433..17ebdac 100644 --- a/mockfirestore/document.py +++ b/mockfirestore/document.py @@ -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)) From 2eb02eb36b008abaebe9ee12070b548889a0f973 Mon Sep 17 00:00:00 2001 From: thromer Date: Thu, 16 Jan 2025 08:51:55 -0800 Subject: [PATCH 4/5] Update python versions in test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e82071d..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.7', '3.8', '3.9', '3.10', '3.11', '3.12' ] + python-version: [ '3.11', '3.12', '3.13' ] steps: - uses: actions/checkout@v2 From 84b41c43ec4fd14169879bb471362c397fb59760 Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Thu, 16 Jan 2025 21:57:34 -0800 Subject: [PATCH 5/5] Make behavior and type signature of DocumentSnapshot.to_dict consistent with Firestore. --- mockfirestore/document.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mockfirestore/document.py b/mockfirestore/document.py index 17ebdac..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: