Skip to content

Commit

Permalink
add mongomock
Browse files Browse the repository at this point in the history
  • Loading branch information
abyesilyurt committed Apr 29, 2024
1 parent 2b4d773 commit f064176
Show file tree
Hide file tree
Showing 61 changed files with 25,135 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ import_heading_localfolder=relative
ignore_comments=False
force_grid_wrap=True
honor_noqa=True
skip_glob = packages/syft/src/syft/__init__.py,packages/grid/data/*
skip_glob=packages/syft/src/syft/__init__.py,packages/grid/data/*,third_party/mongomock/*
21 changes: 11 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,41 @@ repos:
rev: v4.5.0
hooks:
- id: check-ast
exclude: ^(packages/grid/ansible/)
exclude: ^(packages/grid/ansible/|third_party)
always_run: true
- id: trailing-whitespace
always_run: true
exclude: ^(docs/|.+\.md|.bumpversion.cfg)
exclude: ^(docs/|.+\.md|.bumpversion.cfg|third_party)
- id: check-docstring-first
always_run: true
exclude: ^(packages/grid/ansible/)
exclude: ^(packages/grid/ansible/|third_party)
- id: check-json
always_run: true
exclude: ^(packages/grid/frontend/)
exclude: ^(packages/grid/frontend/|third_party)
- id: check-added-large-files
always_run: true
exclude: ^(packages/grid/backend/wheels/.*|docs/img/header.png|docs/img/terminalizer.gif)
- id: check-yaml
always_run: true
exclude: ^(packages/grid/k8s/rendered/|packages/grid/helm/)
exclude: ^(packages/grid/k8s/rendered/|packages/grid/helm/|third_party)
- id: check-merge-conflict
always_run: true
args: ["--assume-in-merge"]
- id: check-executables-have-shebangs
always_run: true
exclude: ^(packages/grid/ansible/)
exclude: ^(packages/grid/ansible/|third_party)
- id: debug-statements
always_run: true
exclude: ^(packages/grid/ansible/)
exclude: ^(packages/grid/ansible/|third_party)
- id: name-tests-test
always_run: true
exclude: ^(.*/tests/utils/)|^(.*fixtures.py)
exclude: ^(.*/tests/utils/)|^(.*fixtures.py|third_party)
- id: requirements-txt-fixer
always_run: true
exclude: "third_party"
- id: mixed-line-ending
args: ["--fix=lf"]
exclude: '\.bat|\.csv|\.ps1$'
exclude: '\.bat|\.csv|\.ps1$|third_party'

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
Expand Down Expand Up @@ -203,7 +204,7 @@ repos:
rev: "v3.0.0-alpha.9-for-vscode"
hooks:
- id: prettier
exclude: ^(packages/grid/helm|packages/grid/frontend/pnpm-lock.yaml|packages/hagrid/hagrid/manifest_template.yml)
exclude: ^(packages/grid/helm|packages/grid/frontend/pnpm-lock.yaml|packages/hagrid/hagrid/manifest_template.yml|third_party)

# - repo: meta
# hooks:
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# third party
from faker import Faker
import mongomock
import pytest

# syft absolute
Expand All @@ -37,6 +36,7 @@
from .syft.stores.store_fixtures_test import sqlite_queue_stash # noqa: F401
from .syft.stores.store_fixtures_test import sqlite_store_partition # noqa: F401
from .syft.stores.store_fixtures_test import sqlite_workspace # noqa: F401
from .utils.mongomock import mongomock


def patch_protocol_file(filepath: Path):
Expand Down
53 changes: 53 additions & 0 deletions third_party/mongomock/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
AUTHORS
ChangeLog

#### Python
*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
.eggs/
parts
bin
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
.achievements
.cache/

#### Eclipse
*.pydevproject
.project
.metadata

# Intellij project files
*.iml
*.ipr
*.iws
.idea

#### Emacs
\#*\#
.#*

#### C/C++
*.o

#### Haskell
*.hi
flycheck-*
.DS_Store
.env

### vim
.ropeproject/
72 changes: 72 additions & 0 deletions third_party/mongomock/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
language: python
cache: pip
os: linux
dist: focal # OS+dist should be kept in sync with Dockerfile and UBUNTU_VERSION below.
env:
global:
# Ubuntu version, keep in sync with os + dist above.
- UBUNTU_VERSION=2004
# MongoDB version should be kept in sync with docker-compose image and mongomock/__init__.py
- MONGODB=5.0.5
jobs:
include:
- python: pypy3
env: TOX_ENV=pypy3-pymongo-pyexecjs
- python: 3.6
env: TOX_ENV=py36-pymongo-pyexecjs
- python: 3.7
env: TOX_ENV=py37-pymongo-pyexecjs
- python: 3.8
env: TOX_ENV=py38-pymongo-pyexecjs
- python: 3.9
env: TOX_ENV=py39-pymongo361-pyexecjs
- python: 3.9
env: TOX_ENV=py39-pymongo-pyexecjs
- python: "3.10"
env: TOX_ENV=py310
- python: "3.10"
env: TOX_ENV=py310-pymongo
- python: "3.10"
env: TOX_ENV=py310-pyexecjs
- python: "3.10"
env: TOX_ENV=py310-pymongo-pyexecjs
- python: "3.10"
env: TOX_ENV=pep8
- python: "3.10"
env: TOX_ENV=pylint
- python: "3.10"
env: TOX_ENV=mypy
- python: "3.10"
env: TOX_ENV=py310-pymongo-pyexecjs-mongodb4 MONGODB=4.4.0
script:
- tox -e $TOX_ENV
before_install:
- "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10"
- "sudo apt-get update"
- "sudo apt-get install libcurl4 -y"
before_script:
- mkdir ${PWD}/mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}/data
- ${PWD}/mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}/bin/mongod --dbpath ${PWD}/mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}/data --logpath ${PWD}/mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}/mongodb.log --fork
- "until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done"
after_script:
- pkill mongod
install:
- wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}.tgz
- tar xzf mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}.tgz
- ${PWD}/mongodb-linux-x86_64-ubuntu${UBUNTU_VERSION}-${MONGODB}/bin/mongod --version
- pip install tox
deploy:
provider: pypi
username: __token__
distributions: "bdist_wheel sdist"
password:
secure: "V77o/nLMWGzQ83Ilpb7zqLmQZAGWRScAQDqloBFeriJXrjh8IFETjl4euWYNbFPzlImXb/ujxYoW0Jd3IdWY/WNTgWaasW++RRBSguwhMzAYZrL2xLOMw23zFOtvOuQ9JEKSJyS3G3GvadUdzQC1Wt/H6LPOuclxJF5oIgQUVU9T4mXpr6xMhw1D86joLCFD
juzvZux02CDfUryRmcNqVd8KDYcs7JCLC9bgJxEB/7nBJEdICONZ8J/kGaiMEFDfplgdpAfR1KX/sVBEMYBCG5eDin1S2Bi22mgJ6FRsTegd5dy1sj+sT+sATmWJ8IlCpnkCszg/psQRmSiSkNEpH2mSUp3KZLspUSS+E9gWwbOyYGR+5OwHQ0NQzfCyPf8nADP/l1v3Wxdw
4gqZUynAmV4cWmGP1tnKCpgkGvTr3QRCLmjQGXPnhgYOcJpu6TT5UhmdB5dhdVWYgYqGu27pjAVy+grK9GmtHYAg5MmZC0v6GClEsxeA/qXe9McyFU13YHKppmAelzIcewy+tJxwFmFSPvscHK8Q/j58C5NIOBqVT9GR3jWQqtsvA8yCxmp/KD1sPSF1KSHHUHlCMlmOpmzc
ZLkLaskRWqznM6wxiLs8UeuyaEEA5R/BdZs4oNZFm9ls0gsf5GPZA6r+8GI5OrSWs6uun/+Th+Xys9yNiMU="
on:
condition: "$TOX_ENV = py310"
python: "3.10"
tags: true
all_branches: true
repo: mongomock/mongomock
19 changes: 19 additions & 0 deletions third_party/mongomock/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# OS+dist should be kept in sync with .travis.yml
FROM ubuntu:focal

RUN apt-get update && apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev git netcat
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH

RUN eval "$(pyenv init -)" && eval "$(pyenv virtualenv-init -)"
RUN pyenv install 3.6.15
RUN pyenv install 3.7.9
RUN pyenv install 3.8.12
RUN pyenv install 3.9.10
RUN pyenv install pypy3.8-7.3.7
RUN pyenv install 3.10.2
RUN pyenv local 3.6.15 3.7.9 3.8.12 3.9.10 3.10.2 pypy3.8-7.3.7

RUN pip install tox
24 changes: 24 additions & 0 deletions third_party/mongomock/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2012, Rotem Yaari <vmalloc@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of organization nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY Rotem Yaari ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Rotem Yaari BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 changes: 9 additions & 0 deletions third_party/mongomock/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include tox.ini
include tests/*.py
include *.rst
include *.txt
include AUTHORS
include Changelog
include LICENSE
include Makefile
recursive-include tests *.json
23 changes: 23 additions & 0 deletions third_party/mongomock/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
default: test

detox-test:
detox

travis-test: test

test: env
.env/bin/nosetests -w tests

coverage-test: env
.env/bin/coverage run .env/bin/nosetests -w tests

env: .env/.up-to-date

.env/.up-to-date: setup.py Makefile
virtualenv .env
.env/bin/pip install -e .
.env/bin/pip install nose coverage PyExecJS pymongo
touch .env/.up-to-date

.PHONY: doc

44 changes: 44 additions & 0 deletions third_party/mongomock/Missing_Features.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
What is this?
-------------
This document lists down the features missing in mongomock library. PRs for these features are highly appreciated.

If I miss to include a feature in the below list, Please feel free to add to the below list and raise a PR.

* $rename complex operations - https://docs.mongodb.com/manual/reference/operator/update/rename/
* create_collection options - https://docs.mongodb.com/v3.2/reference/method/db.createCollection/#definition
* bypass_document_validation options
* session options
* codec options
* Operations of the aggregate pipeline:
* `$bucketAuto <https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/>`_
* `$collStats <https://docs.mongodb.com/manual/reference/operator/aggregation/collStats/>`_
* `$currentOp <https://docs.mongodb.com/manual/reference/operator/aggregation/currentOp/>`_
* `$geoNear <https://docs.mongodb.com/manual/reference/operator/aggregation/geoNear/>`_
* `$indexStats <https://docs.mongodb.com/manual/reference/operator/aggregation/indexStats/>`_
* `$listLocalSessions <https://docs.mongodb.com/manual/reference/operator/aggregation/listLocalSessions/>`_
* `$listSessions <https://docs.mongodb.com/manual/reference/operator/aggregation/listSessions/>`_
* `$merge <https://docs.mongodb.com/manual/reference/operator/aggregation/merge/>`_
* `$planCacheStats <https://docs.mongodb.com/manual/reference/operator/aggregation/planCacheStats/>`_
* `$redact <https://docs.mongodb.com/manual/reference/operator/aggregation/redact/>`_
* `$replaceWith <https://docs.mongodb.com/manual/reference/operator/aggregation/replaceWith/>`_
* `$sortByCount <https://docs.mongodb.com/manual/reference/operator/aggregation/sortByCount/>`_
* `$unset <https://docs.mongodb.com/manual/reference/operator/aggregation/unset/>` _
* Operators within the aggregate pipeline:
* Arithmetic operations on dates:
* `$add <https://docs.mongodb.com/manual/reference/operator/aggregation/add/>`_
* Some date operators ($isoDayOfWeek, $isoWeekYear, …)
* Some set operators ($setIntersection, $setDifference, …)
* Some string operators ($indexOfBytes, $trim, …)
* Text search operator ($meta)
* Projection operator $map
* Array operators ($isArray, $indexOfArray, …)
* `$mergeObjects <https://docs.mongodb.com/manual/reference/operator/aggregation/mergeObjects/>`_
* Some type conversion operators ($convert, …)
* Operators within the query language (find):
* `$jsonSchema <https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/>`_
* `$text <https://docs.mongodb.com/manual/reference/operator/query/text/>`_ search
* `$where <https://docs.mongodb.com/manual/reference/operator/query/where/>`_
* `map_reduce <https://docs.mongodb.com/manual/reference/command/mapReduce/>`_ options (``scope`` and ``finalize``)
* Database `command <https://docs.mongodb.com/manual/reference/command/>`_ method except for the ``ping`` command.
* Raw Batch BSON operations (`aggregate_raw_batches` and `find_raw_batches`)
* `Expiring Data <https://docs.mongodb.com/manual/tutorial/expire-data/>`_

0 comments on commit f064176

Please sign in to comment.