pytest-mongo


Namepytest-mongo JSON
Version 3.1.0 PyPI version JSON
download
home_page
SummaryMongoDB process and client fixtures plugin for Pytest.
upload_time2024-03-13 14:30:39
maintainer
docs_urlNone
author
requires_python>=3.8
licenseGNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
keywords tests pytest fixture mongodb mongo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            .. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-mongo/master/logo.png
    :width: 100px
    :height: 100px
    
pytest-mongo
============

.. image:: https://img.shields.io/pypi/v/pytest-mongo.svg
    :target: https://pypi.python.org/pypi/pytest-mongo/
    :alt: Latest PyPI version

.. image:: https://img.shields.io/pypi/wheel/pytest-mongo.svg
    :target: https://pypi.python.org/pypi/pytest-mongo/
    :alt: Wheel Status

.. image:: https://img.shields.io/pypi/pyversions/pytest-mongo.svg
    :target: https://pypi.python.org/pypi/pytest-mongo/
    :alt: Supported Python Versions

.. image:: https://img.shields.io/pypi/l/pytest-mongo.svg
    :target: https://pypi.python.org/pypi/pytest-mongo/
    :alt: License


What is this?
=============

This is a pytest plugin, that enables you to test your code that relies on a running MongoDB database.
It allows you to specify fixtures for MongoDB process and client.

How to use
==========

Plugin contains two fixtures

* **mongodb** - it's a client fixture that has functional scope, and which cleans MongoDB at the end of each test.
* **mongo_proc** - session scoped fixture, that starts MongoDB instance at the first use and stops at the end of the tests.
* **mongo_noproc** - a no process fixture, that's connecting to already
  running mongodb instance.
  For example on dockerized test environments, or CI providing mongodb services

Simply include one of these fixtures into your tests fixture list.

You can also create additional MongoDB client and process fixtures if you'd need to:


.. code-block:: python

    from pytest_mongo import factories

    mongo_my_proc = factories.mongo_proc(
        port=None, logsdir='/tmp')
    mongo_my = factories.mongodb('mongo_my_proc')

.. note::

    Each MongoDB process fixture can be configured in a different way than the others through the fixture factory arguments.


Connecting to already existing mongodb database
-----------------------------------------------

Some projects are using already running MongoDB servers (ie on docker instances).
In order to connect to them, one would be using the ``mongo_noproc`` fixture.

.. code-block:: python

    mongo_external = factories.mongodb('mongo_noproc')

By default the  ``mongo_noproc`` fixture would connect to MongoDB instance using **27017** port. Standard configuration options apply to it.

These are the configuration options that are working on all levels with the ``mongo_noproc`` fixture:

Configuration
=============

You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option.
You can pick which you prefer, but remember that these settings are handled in the following order:

    * ``Fixture factory argument``
    * ``Command line option``
    * ``Configuration option in your pytest.ini file``

.. list-table:: Configuration options
   :header-rows: 1

   * - MongoDB server option
     - Fixture factory argument
     - Command line option
     - pytest.ini option
     - Noop process fixture
     - Default
   * - Path to mongodb exec
     - executable
     - --mongo-exec
     - mongo_exec
     - no
     - /usr/bin/mongod
   * - MongoDB host
     - host
     - --mongo-host
     - mongo_host
     - 127.0.0.1
     - 127.0.0.1
   * - MongoDB port
     - port
     - --mongo-port
     - port
     - 27017
     - random
   * - Path to store logs
     - logsdir
     - --mongo-logsdir
     - mongo_logsdir
     - no
     - $TMPDIR
   * - Additional parameters
     - params
     - --mongo-params
     - mongo_params
     - no
     -
   * - MongoDB client's time zone awarness
     - tz_aware
     - --mongo-tz-aware
     - mongo_tz_aware
     - no
     - False


Example usage:

* pass it as an argument in your own fixture

    .. code-block:: python

        mongo_proc = factories.mongo_proc(port=8888)

* use ``--mongo-port`` command line option when you run your tests

    .. code-block:: sh

        py.test tests --mongo-port=8888


* specify your directory as ``mongo_port`` in your ``pytest.ini`` file.

    To do so, put a line like the following under the ``[pytest]`` section of your ``pytest.ini``:

    .. code-block:: ini

        [pytest]
        mongo_port = 8888

Package resources
-----------------

* Bug tracker: https://github.com/ClearcodeHQ/pytest-mongo/issues

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pytest-mongo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "tests,pytest,fixture,mongodb,mongo",
    "author": "",
    "author_email": "Grzegorz \u015aliwi\u0144ski <fizyk+pypi@fizyk.dev>",
    "download_url": "https://files.pythonhosted.org/packages/c9/2b/5475d39f34a976fed5b8468e5194b584d9177522e8ec1759f0ca5f639f54/pytest-mongo-3.1.0.tar.gz",
    "platform": null,
    "description": ".. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-mongo/master/logo.png\n    :width: 100px\n    :height: 100px\n    \npytest-mongo\n============\n\n.. image:: https://img.shields.io/pypi/v/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/wheel/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: Wheel Status\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: Supported Python Versions\n\n.. image:: https://img.shields.io/pypi/l/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: License\n\n\nWhat is this?\n=============\n\nThis is a pytest plugin, that enables you to test your code that relies on a running MongoDB database.\nIt allows you to specify fixtures for MongoDB process and client.\n\nHow to use\n==========\n\nPlugin contains two fixtures\n\n* **mongodb** - it's a client fixture that has functional scope, and which cleans MongoDB at the end of each test.\n* **mongo_proc** - session scoped fixture, that starts MongoDB instance at the first use and stops at the end of the tests.\n* **mongo_noproc** - a no process fixture, that's connecting to already\n  running mongodb instance.\n  For example on dockerized test environments, or CI providing mongodb services\n\nSimply include one of these fixtures into your tests fixture list.\n\nYou can also create additional MongoDB client and process fixtures if you'd need to:\n\n\n.. code-block:: python\n\n    from pytest_mongo import factories\n\n    mongo_my_proc = factories.mongo_proc(\n        port=None, logsdir='/tmp')\n    mongo_my = factories.mongodb('mongo_my_proc')\n\n.. note::\n\n    Each MongoDB process fixture can be configured in a different way than the others through the fixture factory arguments.\n\n\nConnecting to already existing mongodb database\n-----------------------------------------------\n\nSome projects are using already running MongoDB servers (ie on docker instances).\nIn order to connect to them, one would be using the ``mongo_noproc`` fixture.\n\n.. code-block:: python\n\n    mongo_external = factories.mongodb('mongo_noproc')\n\nBy default the  ``mongo_noproc`` fixture would connect to MongoDB instance using **27017** port. Standard configuration options apply to it.\n\nThese are the configuration options that are working on all levels with the ``mongo_noproc`` fixture:\n\nConfiguration\n=============\n\nYou can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option.\nYou can pick which you prefer, but remember that these settings are handled in the following order:\n\n    * ``Fixture factory argument``\n    * ``Command line option``\n    * ``Configuration option in your pytest.ini file``\n\n.. list-table:: Configuration options\n   :header-rows: 1\n\n   * - MongoDB server option\n     - Fixture factory argument\n     - Command line option\n     - pytest.ini option\n     - Noop process fixture\n     - Default\n   * - Path to mongodb exec\n     - executable\n     - --mongo-exec\n     - mongo_exec\n     - no\n     - /usr/bin/mongod\n   * - MongoDB host\n     - host\n     - --mongo-host\n     - mongo_host\n     - 127.0.0.1\n     - 127.0.0.1\n   * - MongoDB port\n     - port\n     - --mongo-port\n     - port\n     - 27017\n     - random\n   * - Path to store logs\n     - logsdir\n     - --mongo-logsdir\n     - mongo_logsdir\n     - no\n     - $TMPDIR\n   * - Additional parameters\n     - params\n     - --mongo-params\n     - mongo_params\n     - no\n     -\n   * - MongoDB client's time zone awarness\n     - tz_aware\n     - --mongo-tz-aware\n     - mongo_tz_aware\n     - no\n     - False\n\n\nExample usage:\n\n* pass it as an argument in your own fixture\n\n    .. code-block:: python\n\n        mongo_proc = factories.mongo_proc(port=8888)\n\n* use ``--mongo-port`` command line option when you run your tests\n\n    .. code-block:: sh\n\n        py.test tests --mongo-port=8888\n\n\n* specify your directory as ``mongo_port`` in your ``pytest.ini`` file.\n\n    To do so, put a line like the following under the ``[pytest]`` section of your ``pytest.ini``:\n\n    .. code-block:: ini\n\n        [pytest]\n        mongo_port = 8888\n\nPackage resources\n-----------------\n\n* Bug tracker: https://github.com/ClearcodeHQ/pytest-mongo/issues\n",
    "bugtrack_url": null,
    "license": "GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.   This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.  0. Additional Definitions.  As used herein, \"this License\" refers to version 3 of the GNU Lesser General Public License, and the \"GNU GPL\" refers to version 3 of the GNU General Public License.  \"The Library\" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.  An \"Application\" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.  A \"Combined Work\" is a work produced by combining or linking an Application with the Library.  The particular version of the Library with which the Combined Work was made is also called the \"Linked Version\".  The \"Minimal Corresponding Source\" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.  The \"Corresponding Application Code\" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.  1. Exception to Section 3 of the GNU GPL.  You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.  2. Conveying Modified Versions.  If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:  a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or  b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.  3. Object Code Incorporating Material from Library Header Files.  The object code form of an Application may incorporate material from a header file that is part of the Library.  You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:  a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.  b) Accompany the object code with a copy of the GNU GPL and this license document.  4. Combined Works.  You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:  a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.  b) Accompany the Combined Work with a copy of the GNU GPL and this license document.  c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.  d) Do one of the following:  0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.  1) Use a suitable shared library mechanism for linking with the Library.  A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.  e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)  5. Combined Libraries.  You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:  a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.  b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.  6. Revised Versions of the GNU Lesser General Public License.  The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.  Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License \"or any later version\" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.  If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.",
    "summary": "MongoDB process and client fixtures plugin for Pytest.",
    "version": "3.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/ClearcodeHQ/pytest-mongo/issues",
        "Changelog": "https://github.com/ClearcodeHQ/pytest-mongo/blob/v3.1.0/CHANGES.rst",
        "Source": "https://github.com/ClearcodeHQ/pytest-mongo"
    },
    "split_keywords": [
        "tests",
        "pytest",
        "fixture",
        "mongodb",
        "mongo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33df04aba78171d32a3175d3985cf7107506e715a745f868d869fe545adc655b",
                "md5": "6dc509349f72bb0f9fb274330af708af",
                "sha256": "3648cde5c81d86fefe16f408a3d18ea729f78d0826dc48311b7077bf8b9a88f0"
            },
            "downloads": -1,
            "filename": "pytest_mongo-3.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6dc509349f72bb0f9fb274330af708af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14358,
            "upload_time": "2024-03-13T14:30:37",
            "upload_time_iso_8601": "2024-03-13T14:30:37.661248Z",
            "url": "https://files.pythonhosted.org/packages/33/df/04aba78171d32a3175d3985cf7107506e715a745f868d869fe545adc655b/pytest_mongo-3.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c92b5475d39f34a976fed5b8468e5194b584d9177522e8ec1759f0ca5f639f54",
                "md5": "3467cecf39d2865d4ad9d793a3efb39b",
                "sha256": "a4e3218ab3d4902acb536f04f7c60ff2a33da3bde3b7d6fe8d5f976c75a3ded9"
            },
            "downloads": -1,
            "filename": "pytest-mongo-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3467cecf39d2865d4ad9d793a3efb39b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16606,
            "upload_time": "2024-03-13T14:30:39",
            "upload_time_iso_8601": "2024-03-13T14:30:39.855863Z",
            "url": "https://files.pythonhosted.org/packages/c9/2b/5475d39f34a976fed5b8468e5194b584d9177522e8ec1759f0ca5f639f54/pytest-mongo-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-13 14:30:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ClearcodeHQ",
    "github_project": "pytest-mongo",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pytest-mongo"
}
        
Elapsed time: 0.20313s