From 6554df5aa9e3e33ef10cabd2081e7678aca6be5c Mon Sep 17 00:00:00 2001 From: Andrei Gherasim Date: Mon, 10 Jul 2023 00:21:45 +0200 Subject: [PATCH 1/3] Refs #72, adding support for transactions argument --- mockfirestore/document.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mockfirestore/document.py b/mockfirestore/document.py index 24aa433..fd46b18 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, Optional from mockfirestore import NotFound from mockfirestore._helpers import ( Timestamp, Document, Store, get_by_path, set_by_path, delete_by_path @@ -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, transaction=None) -> Any: if not self.exists: return None else: From a241913cd396fb0e3566068b02e95da306647c36 Mon Sep 17 00:00:00 2001 From: Andrei Gherasim Date: Mon, 10 Jul 2023 00:24:15 +0200 Subject: [PATCH 2/3] Refs #72, adding support for transactions argument --- mockfirestore/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mockfirestore/document.py b/mockfirestore/document.py index fd46b18..28839db 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, Optional +from typing import List, Dict, Any from mockfirestore import NotFound from mockfirestore._helpers import ( Timestamp, Document, Store, get_by_path, set_by_path, delete_by_path From 48966588cbb7c4769d836805f3ae51cef27f7d01 Mon Sep 17 00:00:00 2001 From: Andrei Gherasim Date: Mon, 10 Jul 2023 21:43:00 +0200 Subject: [PATCH 3/3] Further fixes for missing features: transactions in DocumentReference; path property in DocumentReference --- mockfirestore/document.py | 6 +++++- setup.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mockfirestore/document.py b/mockfirestore/document.py index 28839db..8778d7c 100644 --- a/mockfirestore/document.py +++ b/mockfirestore/document.py @@ -63,7 +63,11 @@ def __init__(self, data: Store, path: List[str], def id(self): return self._path[-1] - def get(self) -> DocumentSnapshot: + @property + def path(self): + return "/".join(self._path) + + def get(self, transaction=None) -> DocumentSnapshot: return DocumentSnapshot(self, get_by_path(self._data, self._path)) def delete(self): diff --git a/setup.py b/setup.py index f55cb88..669ca7a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="mock-firestore", - version="0.11.0", + version="0.11.3", author="Matt Dowds", description="In-memory implementation of Google Cloud Firestore for use in tests", long_description=long_description, @@ -21,4 +21,4 @@ 'Programming Language :: Python :: 3.10', "License :: OSI Approved :: MIT License", ], -) \ No newline at end of file +)