{ "info": { "author": "Lovely Systems", "author_email": "office@lovelysystems.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3" ], "description": "====================\nLovely Pytest Docker\n====================\n\n.. image:: https://img.shields.io/pypi/v/lovely-pytest-docker.svg\n :target: https://pypi.org/project/lovely-pytest-docker/\n\n.. image:: https://img.shields.io/pypi/pyversions/lovely-pytest-docker.svg\n :target: https://pypi.org/project/lovely-pytest-docker/\n\n.. image:: https://travis-ci.com/lovelysystems/lovely-pytest-docker.svg?branch=master\n :target: https://travis-ci.com/lovelysystems/lovely-pytest-docker\n\n\nCreate simple Pytest_ fixtures for writing integration tests based on Docker\ncontainers. The framework provides a service class to start and stop containers\nbased Docker Compose. Each single container can be started individually.\n\nSome parts of this package are taken from\nhttps://github.com/AndreLouisCaron/pytest-docker\n\n\nUsage with Pytest\n=================\n\nThe docker compose file should contain all desired containers and the ports\nshould be exposed. In the following example we want to start the app to test\nand a SQL database (Crate). Let's assume there is a ``Dockerfile`` for the app\nin the same folder as the docker compose file::\n\n version: \"3\"\n services:\n app:\n build: .\n ports:\n - \"8080\"\n depends_on:\n - \"crate\"\n\n crate:\n image: crate:latest\n ports:\n - \"4200\"\n\nIn the ``conftest.py`` file we can declare the docker fixtures for each service\nwe want to be able to start in the tests::\n\n import pytest\n\n @pytest.fixture(scope='session')\n def docker_app(docker_services):\n docker_services.start('app')\n public_port = docker_services.wait_for_service(\"app\", 8080)\n url = \"http://{docker_services.docker_ip}:{public_port}\".format(**locals())\n return url\n\n @pytest.fixture(scope='session')\n def docker_crate(docker_services):\n docker_services.start('crate')\n public_port = docker_services.wait_for_service(\"crate\", 4200)\n dsn = \"{docker_services.docker_ip}:{public_port}\".format(**locals())\n return dsn\n\nBy default the fixture will look for the ``docker-compose.yml`` file in the\n``tests`` subfolder of the path where ``pytest.ini`` resides (or the project's\nroot directory if no ini file is given - as in the tests example). In many\ncases you will want to override the location for the docker compose files. Just\noverwrite the ``docker_compose_files`` fixture in your ``conftest.py`` file::\n\n @pytest.fixture(scope='session')\n def docker_compose_files(pytestconfig):\n \"\"\"Get the docker-compose.yml absolute path.\n Override this fixture in your tests if you need a custom location.\n \"\"\"\n return [\n project_path('docker', 'docker-compose.yml'),\n ]\n\nIn your test file declare the fixtures you want to use::\n\n def test_something(docker_app, docker_crate):\n # e.g. initialize database\n ...\n # test something (e.g. request to docker_app)\n ...\n\nA working configuration and test example can be found in the ``tests`` folder\nof this package.\n\n\nExecution in Docker Container\n=============================\n\nIt's possible to execute a command inside one of the Docker containers. Use\nthe ``exec`` method of the ``docker_services`` fixture::\n\n def test_exec(docker_services):\n # the first argument is the service name of the compose file,\n # the following arguments build the command to run\n res = docker_services.exec('crate', 'ls', '-a')\n\n\nWait for Service\n================\n\nThe ``wait_for_service`` method of the service module checks whether the\ndocker service is really started. By default it makes a HTTP GET request to the\nserver's ``/`` endpoint. The service will retry to check until a timeout of\n30 seconds has passed.\n\nCustom Service Checker\n----------------------\n\nSome services may work differently and require a custom checker.\n\nCreate a custom service checker function which receives the IP address and the\nport as parameters::\n\n def custom_service_checker(ip_address, port):\n # if service is ready\n return True\n # otherwise return False\n\nIn the fixture provide the custom service checker function as ``check_service``\nparameter to the ``wait_for_service`` method::\n\n @pytest.fixture(scope='session')\n def docker_custom_service(docker_services):\n docker_services.start('custom_service')\n public_port = docker_services.wait_for_service(\n \"app\",\n 8080,\n check_service=custom_service_checker\n )\n url = \"http://{docker_services.docker_ip}:{public_port}\".format(**locals())\n return url\n\n\nRun Tests\n=========\n\nTests are held in the ``tests`` directory. Running tests is done via the\npytest package with::\n\n ./gradlew pytest\n\n\n.. _Pytest: http://doc.pytest.org\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lovelysystems/lovely-pytest-docker", "keywords": "pytest testing docker compose", "license": "", "maintainer": "", "maintainer_email": "", "name": "lovely-pytest-docker", "package_url": "https://pypi.org/project/lovely-pytest-docker/", "platform": "", "project_url": "https://pypi.org/project/lovely-pytest-docker/", "project_urls": { "Homepage": "https://github.com/lovelysystems/lovely-pytest-docker" }, "release_url": "https://pypi.org/project/lovely-pytest-docker/0.1.0/", "requires_dist": [ "pytest" ], "requires_python": "", "summary": "Pytest testing utilities with docker containers.", "version": "0.1.0" }, "last_serial": 5736293, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "7842ed71215d20c20c2b3c1d4d1c478e", "sha256": "0bce37360c67d8c2438ca1a9490368d4bc594e44d75de45676101c459927d9a3" }, "downloads": -1, "filename": "lovely-pytest-docker-0.0.2.tar.gz", "has_sig": false, "md5_digest": "7842ed71215d20c20c2b3c1d4d1c478e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5598, "upload_time": "2018-01-10T14:45:16", "url": "https://files.pythonhosted.org/packages/88/3d/d3f3fb225c91bec2a1be88902b6ad6dfc1e239ad62f56b028b8c9122fc45/lovely-pytest-docker-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "ef348722a26de377e748a3d28acc54b1", "sha256": "238ed21dd56d070dfd23e78663ecdb8ff49a7c24f5fa1c370e4fb95476f5b1ae" }, "downloads": -1, "filename": "lovely-pytest-docker-0.0.3.tar.gz", "has_sig": false, "md5_digest": "ef348722a26de377e748a3d28acc54b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5608, "upload_time": "2018-02-21T13:16:15", "url": "https://files.pythonhosted.org/packages/a0/ab/a93c9060aab4ab3487c2487a0a2c468f9858168fbd55694de3bc7ee75903/lovely-pytest-docker-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "30e08fdc3a2f8d728f6ae88d27680bfa", "sha256": "3ac8be8c1dd6466b4696373de840b5e821216f6e07667907201aea382dc5f87e" }, "downloads": -1, "filename": "lovely-pytest-docker-0.0.4.tar.gz", "has_sig": false, "md5_digest": "30e08fdc3a2f8d728f6ae88d27680bfa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5620, "upload_time": "2018-12-20T14:34:31", "url": "https://files.pythonhosted.org/packages/cb/5a/e780d9a2ce59a42046b98a7570311e709b17529944b38d03723db0801f4b/lovely-pytest-docker-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "17ca12e26c86c218c383ebaf0ff7860b", "sha256": "01aabd2fff90e65b587489a9d5d598b450298815bd6056c90678d9091e666664" }, "downloads": -1, "filename": "lovely-pytest-docker-0.0.5.tar.gz", "has_sig": false, "md5_digest": "17ca12e26c86c218c383ebaf0ff7860b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5700, "upload_time": "2019-01-22T07:56:56", "url": "https://files.pythonhosted.org/packages/8c/58/3b6eae03544401bd78a6043decb6d6daab8ac24649570076dae4c7bbda47/lovely-pytest-docker-0.0.5.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "69cecded5e1c54686a7bf498bd4d665b", "sha256": "7694a0194b082665edd5729c62513ea38f4320d6268d6f5f9485e878966f93be" }, "downloads": -1, "filename": "lovely_pytest_docker-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "69cecded5e1c54686a7bf498bd4d665b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10924, "upload_time": "2019-08-27T11:49:14", "url": "https://files.pythonhosted.org/packages/a8/0a/4c2157ab42e4ec9da1e3cef3b20039a96f8e8abe03cba9f5d3a3ed64ffb6/lovely_pytest_docker-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6ba4b7468e32f5f1890bc76eb8994535", "sha256": "f471f442daad56f26660e8c31a075a82c28f5196ecc2d58658cf6516d9eb2cd0" }, "downloads": -1, "filename": "lovely-pytest-docker-0.1.0.tar.gz", "has_sig": false, "md5_digest": "6ba4b7468e32f5f1890bc76eb8994535", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5784, "upload_time": "2019-08-27T11:49:16", "url": "https://files.pythonhosted.org/packages/22/9a/09fca8dc52d1d0691649611514e947cc87767b79a7fd0f01bba3e4c4ccc3/lovely-pytest-docker-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "69cecded5e1c54686a7bf498bd4d665b", "sha256": "7694a0194b082665edd5729c62513ea38f4320d6268d6f5f9485e878966f93be" }, "downloads": -1, "filename": "lovely_pytest_docker-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "69cecded5e1c54686a7bf498bd4d665b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10924, "upload_time": "2019-08-27T11:49:14", "url": "https://files.pythonhosted.org/packages/a8/0a/4c2157ab42e4ec9da1e3cef3b20039a96f8e8abe03cba9f5d3a3ed64ffb6/lovely_pytest_docker-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6ba4b7468e32f5f1890bc76eb8994535", "sha256": "f471f442daad56f26660e8c31a075a82c28f5196ecc2d58658cf6516d9eb2cd0" }, "downloads": -1, "filename": "lovely-pytest-docker-0.1.0.tar.gz", "has_sig": false, "md5_digest": "6ba4b7468e32f5f1890bc76eb8994535", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5784, "upload_time": "2019-08-27T11:49:16", "url": "https://files.pythonhosted.org/packages/22/9a/09fca8dc52d1d0691649611514e947cc87767b79a7fd0f01bba3e4c4ccc3/lovely-pytest-docker-0.1.0.tar.gz" } ] }