diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9d734533..29a7e881 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,11 +31,6 @@ jobs: - "postgres" services: - mongodb: - image: mongo - ports: - - 27017:27017 - postgresdb: image: postgres:alpine ports: diff --git a/Makefile b/Makefile index 4d52a184..778fd785 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,9 @@ test: -b \ -X dev \ -Werror \ + -Wignore:::mongomock: \ + -Wignore:::mongomock.__version__: \ + -Wignore:::pkg_resources: \ -m unittest # DOC: Test the examples diff --git a/docs/changelog.rst b/docs/changelog.rst index c5fc0767..f7482039 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -11,6 +11,7 @@ ChangeLog - Add support for Django 5.0 - Add support for Python 3.12 - :issue:`903`: Add basic typing annotations +- Run the test suite against ``mongomock`` instead of an actual mongo server *Bugfix:* diff --git a/setup.cfg b/setup.cfg index 4f93b98c..1882a205 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,6 +51,7 @@ dev = SQLAlchemy sqlalchemy_utils mongoengine + mongomock wheel>=0.32.0 tox zest.releaser[recommended] diff --git a/tests/test_mongoengine.py b/tests/test_mongoengine.py index bc930fca..5c8a9bfa 100644 --- a/tests/test_mongoengine.py +++ b/tests/test_mongoengine.py @@ -12,6 +12,7 @@ import factory from factory.mongoengine import MongoEngineFactory +import mongomock class Address(mongoengine.EmbeddedDocument): @@ -52,6 +53,7 @@ def setUpClass(cls): db=cls.db_name, host=cls.db_host, port=cls.db_port, + mongo_client_class=mongomock.MongoClient, # PyMongo>=2.1 requires an explicit read_preference. read_preference=mongo_rp.ReadPreference.PRIMARY, # PyMongo>=2.1 has a 20s timeout, use 100ms instead diff --git a/tox.ini b/tox.ini index 17dfdb50..caf960cf 100644 --- a/tox.ini +++ b/tox.ini @@ -30,7 +30,6 @@ DATABASE_TYPE = [testenv] passenv = - MONGO_HOST POSTGRES_HOST POSTGRES_DATABASE deps = @@ -38,6 +37,7 @@ deps = alchemy: SQLAlchemy alchemy: sqlalchemy_utils mongo: mongoengine + mongo: mongomock django{32,42,50,main}: Pillow django32: Django>=3.2,<3.3 django42: Django>=4.2,<5.0