diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..0394f8c --- /dev/null +++ b/.github/pull_request_template.md @@ -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'. diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 08f8791..9297fe2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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/* \ No newline at end of file +#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/* 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/mockfirestore/document.py b/mockfirestore/document.py index 24aa433..fa76c02 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, transaction=None) -> Any: if not self.exists: return None else: @@ -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): diff --git a/mockfirestore/query.py b/mockfirestore/query.py index 7a4618d..454dbdd 100644 --- a/mockfirestore/query.py +++ b/mockfirestore/query.py @@ -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 diff --git a/setup.py b/setup.py index f55cb88..82f8a8e 100644 --- a/setup.py +++ b/setup.py @@ -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, @@ -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", ], -) \ No newline at end of file +)