Skip to content
Closed
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
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Summary
A few sentences that describe the purpose of the change you're trying to make.
Succinctly rephrase the issue, do not just link it here.

# Changes
- Go through the diff under this input box.
- Find a bigger 'block' for every changed row and mention the blocks here.
- With every change or block, look back at the **Summary** - does the change contribute to the task?
- If the change does not contribute, it belongs to another PR, don't inflate the scope 🙂.
- If you do a significant revision of your PR after a review, update the changes here.

# Tests
Look at the **Summary**. Which tests do you expect to break given the change you did?
Did those tests break? If not, check what's wrong!

Did you add a functionality that needs new tests? Are those test included in the PR?

# GH
Don't forget to add closing keywords for all the issues this PR fixes here.

# Process
This is just a temporary reminder, please remove the Process section before you submit the PR.

- This is a mandatory template, don't send your PR for review without it.
- Don't approve any PR without the template well filled.
- Use **TODO** blocks in the above sections, with `- [ ]` checkmark lists, if there's things
you want to do before the PR merges, but after you send it to review.
- The size of your PR should be such that a well filled template is still a 'one-pager'.
52 changes: 26 additions & 26 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: Deploy
on:
push:
tags:
- '*'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
#name: Deploy
#on:
# push:
# tags:
# - '*'
#
#jobs:
# deploy:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.x'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install setuptools wheel twine
# - name: Build and publish
# env:
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# python setup.py sdist bdist_wheel
# twine upload dist/*
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.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions mockfirestore/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -63,7 +63,7 @@ def __init__(self, data: Store, path: List[str],
def id(self):
return self._path[-1]

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

def delete(self):
Expand Down
11 changes: 10 additions & 1 deletion mockfirestore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ def stream(self, transaction=None) -> Iterator[DocumentSnapshot]:
if compare(doc_snapshot._get_by_field_path(field), value)]

if self.orders:

def _sort_by(doc: dict, key: str):
"""Allow sorting by nested keys."""
d = doc.to_dict()
# Nesting denoted with '.'
for k in key.split('.'):
d = d[k]
return d

for key, direction in self.orders:
doc_snapshots = sorted(doc_snapshots,
key=lambda doc: doc.to_dict()[key],
key=lambda doc: _sort_by(doc, key),
reverse=direction == 'DESCENDING')
if self._start_at:
document_fields_or_snapshot, before = self._start_at
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="mock-firestore",
version="0.11.0",
version="0.11.2",
author="Matt Dowds",
description="In-memory implementation of Google Cloud Firestore for use in tests",
long_description=long_description,
Expand All @@ -19,6 +19,8 @@
'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