Metadata-Version: 2.1
Name: pytest-dockerc
Version: 1.0.2
Summary: Run, manage and stop Docker Compose project from Docker API
Home-page: https://gitlab.com/nicofonk/pytest-dockerc
Author: Nicolas Gelot
Author-email: nicolas.gelot@vadesecure.com
License: MIT
Description: # pytest-dockerc
        
        **pytest-dockerc** is a plugin for [pytest](https://docs.pytest.org/en/latest/) that provides support
        for running test from [Docker Compose](https://github.com/docker/compose#docker-compose) project.
        The `docker-compose up -d` command is executed at the beginning of the
        test session and the `docker-compose down` command at the end. The main fixture `dockerc`
        returns a [compose.project.Project](https://github.com/docker/compose/blob/master/compose/project.py)
        to deal with the python docker API in your tests. Another fixture `dockerc_logs` is provided to enable
        the logs on stdout during your tests execution.
        
        # Install
        
        ```
        pip install pytest-dockerc
        ```
        
        # Getting started
        
        Below a basic example, you can also refer to a full example with an [http server](tests/tests_fixtures.py).
        
        ## worktree
        
        ```
        ├── docker-compose.yml
        └── tests
            ├── conftest.py
            └── test_example.py
        ```
        
        ## docker-compose.yml
        
        ```yaml
        version: "3.6"
        
        services:
          python:
            image: python:3-alpine
        ```
        
        ## test_example.py
        
        ```python
        def test_example(dockerc):
            assert len(dockerc.containers()) == 1
            container = dockerc.containers()[0]
            assert container.is_running is True
            assert container.labels["com.docker.compose.service"] == "python"
        ```
        
        # Available options
        
        Some options are available with the behavior of the plugin.
        
        ```
        dockerc:                                                                                                                                                                                                                                     
          --dockerc-norun       disable the run and stop commands of docker-compose.
          --dockerc-filepath=DOCKERC_FILEPATH
                                set the Compose file path
          --dockerc-projectdir=DOCKERC_PROJECTDIR
                                set the working directory of the Compose project
          --dockerc-build       build images before starting containers
          --dockerc-services=DOCKERC_SERVICES
                                select services to run
        ```
        
        ## Run tests without up and down command of  **docker-compose**
        
        Running the full **docker-compose** project can take time, if you loads several services. It is
        useful to run the test on a running instance. That method is recommended when you write a new
        test.
        
        First start your docker compose like usual:
        ```
        docker-compose up
        ```
        
        Then run your tests with the `--dockerc-norun`, that will skip the `up` and `down` command:
        ```
        pytest --dockerc-norun
        ```
        
        Below the docker-compose output after 2 runs of the test `tests/test_fixtures::test_basic_workflow`,
        which performs a GET request.
        ```
        Creating network "pytest-dockerc_default" with the default driver
        Creating pytest-dockerc_http_1 ... done
        Attaching to pytest-dockerc_http_1
        http_1  | 192.168.32.1 - - [24/Dec/2018:08:48:21 +0000] "GET / HTTP/1.1" 200 612 "-" "python-requests/2.20.0" "-"
        http_1  | 192.168.32.1 - - [24/Dec/2018:08:48:22 +0000] "GET / HTTP/1.1" 200 612 "-" "python-requests/2.20.0" "-"
        
        ```
        
Keywords: py.test pytest docker docker-compose container
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Utilities
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown
Provides-Extra: tests
