Metadata-Version: 2.1
Name: pytest_service
Version: 0.0.2
License: MIT License
        
        Copyright (c) 2023 Timur Ozheghin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/anna-money/pytest-service
Project-URL: changelog, https://github.com/anna-money/pytest-service/blob/master/CHANGELOG.md
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Pytest
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pytest>=6.0.0
Requires-Dist: docker>=6.1.0
Requires-Dist: requests<2.33.0

# pytest-service

Inspired by [pytest-pg](https://pypi.org/project/pytest-pg/) but with `MongoDB` onboard

### How to use

#### Postgres

```python
@pytest.fixture(scope="session")
def pg_14_local() -> Iterator:
    with pytest_service.PGService("postgres:14.4-alpine").run() as pg:
        yield pg


@pytest.fixture(scope="session", autouse=True)
def init_env(pg_14_local: pytest_service.PG) -> None:
    if not pg_14_local:
        return
    os.environ["POSTGRES_DBNAME"] = pg_14_local.database
    os.environ["POSTGRES_USER"] = pg_14_local.user
    os.environ["POSTGRES_PASSWORD"] = pg_14_local.password
    os.environ["POSTGRES_HOST"] = pg_14_local.host
    os.environ["POSTGRES_PORT"] = str(pg_14_local.port)

```

#### MongoDB

```python
@pytest.fixture(scope="session")
def mongo_6_local() -> Iterator:
    with pytest_service.MongoDBService("mongo:6").run() as mongo:
        yield mongo


@pytest.fixture(scope="session", autouse=True)
def init_env(mongo_6_local: pytest_service.Mongo) -> None:
    if not mongo_6_local:
        return
    os.environ["MONGODB_CONNECTION_STRING"] = mongo_6_local.connection_string

```
