pytest-docker-git-fixtures


Namepytest-docker-git-fixtures JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/crashvb/pytest-docker-git-fixtures
SummaryPytest fixtures for testing with git scm.
upload_time2024-08-12 23:38:18
maintainerNone
docs_urlNone
authorRichard Davis
requires_pythonNone
licenseApache License 2.0
keywords docker fixtures git pytest scm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-docker-git-fixtures

[![pypi version](https://img.shields.io/pypi/v/pytest-docker-git-fixtures.svg)](https://pypi.org/project/pytest-docker-git-fixtures)
[![build status](https://github.com/crashvb/pytest-docker-git-fixtures/actions/workflows/main.yml/badge.svg)](https://github.com/crashvb/pytest-docker-git-fixtures/actions)
[![coverage status](https://coveralls.io/repos/github/crashvb/pytest-docker-git-fixtures/badge.svg)](https://coveralls.io/github/crashvb/pytest-docker-git-fixtures)
[![python versions](https://img.shields.io/pypi/pyversions/pytest-docker-git-fixtures.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/pytest-docker-git-fixtures)
[![linting](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![license](https://img.shields.io/github/license/crashvb/pytest-docker-git-fixtures.svg)](https://github.com/crashvb/pytest-docker-git-fixtures/blob/master/LICENSE.md)

## Overview

Pytest fixtures to instantiate and populated local GIT SCMs, using [lovely-pytest-docker](https://pypi.org/project/lovely-pytest-docker), for testing.

## Getting Started

Update <tt>setup.py</tt> to include:

```python
from distutils.core import setup

setup(
	tests_require=["pytest-docker-git-fixtures"]
)
```

All fixtures should be automatically included via the <tt>pytest11</tt> entry point.
```python
import pytest
import subprocess
from pathlib import Path
from pytest_docker_git_fixtures import GITInsecure, GITSecure  # Optional, for typing

@pytest.mark.create_repo("test_git_secure")
@pytest.mark.mirror_repo("https://github.com/crashvb/shim-bind.git")
def test_git_secure(git_secure: GITSecure, tmp_path: Path):
    uri = f"https://{git_secure.endpoint}/secure/shim-bind.git"
    path = tmp_path.joinpath("local-clone")
    subprocess.run(
        ["git", "clone", uri, str(path)],
        check=True,
        cwd=str(tmp_path),
        stderr=subprocess.STDOUT,
    )
    assert path.joinpath("README.md").exists()

@pytest.mark.create_repo("test_git_insecure")
def test_git_insecure(git_insecure: GITInsecure, tmp_path: Path):
    uri = f"https://{git_insecure.endpoint}/insecure/test_git_insecure.git"
    path = tmp_path.joinpath("local-clone")
    subprocess.run(
        ["git", "clone", uri, str(path)],
        check=True,
        cwd=str(tmp_path),
        stderr=subprocess.STDOUT,
    )
    assert path.exists()
```

The `create_repo` and `mirror_repo` marks can optionally be added to stage repositories in the GIT prior to testing. See [Markers](#markers) for details.

## Installation
### From [pypi.org](https://pypi.org/project/pytest-docker-git-fixtures/)

```
$ pip install pytest_git_fixtures
```

### From source code

```bash
$ git clone https://github.com/crashvb/pytest-docker-git-fixtures
$ cd pytest-docker-git-fixtures
$ virtualenv env
$ source env/bin/activate
$ python -m pip install --editable .[dev]
```

## <a name="fixtures"></a>Fixtures

### <a name="git_auth_header"></a> git_auth_header

Retrieves an HTTP basic authentication header that is populated with credentials that can access the secure GIT service. The credentials are retrieved from the [git_password](#git_password) and [git_username](#git_username) fixtures.

### <a name="git_cacerts"></a> git_cacerts

Locates a user-defined CA trust store (<tt>tests/cacerts</tt>) to use to verify connections to the secure GIT service. If one cannot be located, a temporary trust store is created containing certificates from <tt>certifi</tt> and the [git_certs](#git_certs) fixture. This fixture is used to instantiate the secure GIT service.

### <a name="git_certs"></a> git_certs

Returns the paths of the self-signed certificate authority certificate, certificate, and private key that are used by the secure GIT service. This fixture is used to instantiate the secure GIT service.

#### NamedTuple Fields

The following fields are defined in the tuple provided by this fixture:

* **ca_certificate** - Path to the self-signed certificate authority certificate.
* **ca_private_key** - Path to the self-signed certificate authority private key.
* **certificate** - Path to the certificate.
* **private_key** - Path to the private key.

Typing is provided by `pytest_git_fixtures.GITCerts`.

### <a name="git_hwpasswd"></a> git_htpasswd

Provides the path to a htpasswd file that is used by the secure GIT service. If a user-defined htpasswd file (<tt>tests/htpasswd</tt>) can be located, it is used. Otherwise, a temporary htpasswd file is created using credentials from the [git_password](#git_password) and [git_username](#git_username) fixtures. This fixture is used to instantiate the secure GIT service.

### <a name="git_insecure"></a> git_insecure

Configures and instantiates a GIT without TLS or authentication.

```python
import pytest
import subprocess
from pathlib import Path
from pytest_docker_git_fixtures import GITInsecure  # Optional, for typing

@pytest.mark.create_repo("test_git_insecure")
def test_git_insecure(git_insecure: GITInsecure, tmp_path: Path):
    uri = f"https://{git_insecure.endpoint}/insecure/test_git_insecure.git"
    path = tmp_path.joinpath("local-clone")
    subprocess.run(
        ["git", "clone", uri, str(path)],
        check=True,
        cwd=str(tmp_path),
        stderr=subprocess.STDOUT,
    )
    assert path.exists()
```

#### NamedTuple Fields

The following fields are defined in the tuple provided by this fixture:

* **created_repos** - The list of created repositories.
* **docker_compose** - Path to the fully instantiated docker-compose configuration.
* **endpoint** - Endpoint of the insecure GIT service.
* **endpoint_name** - Endpoint of the insecure GIT service, by service name.
* **mirrored_repos** - The list of mirrored repositories.
* **service_name** - Name of the service within the docker-compose configuration.

Typing is provided by `pytest_git_fixtures.GITInsecure`.

### <a name="git_password"></a> git_password

Provides a generated password to use for authentication to the secure GIT service.

### <a name="git_secure"></a> git_secure

Configures and instantiates a TLS enabled GIT with HTTP basic authorization.

```python
import pytest
import subprocess
from pathlib import Path
from pytest_docker_git_fixtures import GITSecure  # Optional, for typing

@pytest.mark.mirror_repo("https://github.com/crashvb/shim-bind.git")
def test_git_secure(git_secure: GITSecure, tmp_path: Path):
    uri = f"https://{git_secure.endpoint}/secure/shim-bind.git"
    path = tmp_path.joinpath("local-clone")
    subprocess.run(
        ["git", "clone", uri, str(path)],
        check=True,
        cwd=str(tmp_path),
        stderr=subprocess.STDOUT,
    )
    assert path.joinpath("README.md").exists()
```

#### NamedTuple Fields

The following fields are defined in the tuple provided by this fixture:

* **auth_header** - from [git_auth_header](#git_auth_header).
* **cacerts** - from [git_cacerts](#git_cacerts).
* **certs** - from [git_certs](#git_certs).
* **created_repos** - The list of created repositories.
* **docker_compose** - Path to the fully instantiated docker-compose configuration.
* **endpoint** - Endpoint of the secure GIT service.
* **endpoint_name** - Endpoint of the secure GIT service, by service name.
* **htpasswd** - from [git_htpasswd](#git_htpasswd)
* **mirrored_repos** - The list of mirrored repositories.
* **password** - from [git_password](#git_password).
* **service_name** - Name of the service within the docker-compose configuration.
* **ssl_context** - from [git_ssl_context](#git_ssl_context).
* **username** - from [git_username](#git_username).

Typing is provided by `pytest_git_fixtures.GITSecure`.

### <a name="git_ssl_context"></a> git_ssl_context

Provides an SSL context containing the CA trust store from the  [git_cacerts](#git_cacerts) fixture.

### <a name="git_username"></a> git_username

Provides a generated username to use for authentication to the secure GIT service.

### <a name="pdgf_docker_compose_insecure"></a> pdgf_docker_compose_insecure

This fixture uses the `docker_compose_files` fixture to locate a user-defined docker-compose configuration file (typically <tt>tests/docker-compose.yml</tt>) that contains the <tt>pytest-docker-git-insecure</tt> service. If one cannot be located, an embedded configuration is copied to a temporary location and returned. This fixture is used to instantiate the insecure GIT service.

### <a name="pdgf_docker_compose_secure"></a> docker_compose_secure

This fixture uses the `docker_compose_files` fixture to locate a user-defined docker-compose configuration file (typically <tt>tests/docker-compose.yml</tt>) that contains the <tt>pytest-docker-git-secure</tt> service. If one cannot be located, an embedded configuration is copied to a temporary location and returned. This fixture is used to instantiate the secure GIT service; however, unlike the configuration returned by the [pdgf_docker_compose_insecure](#pdgf_docker_compose_insecure) fixture, this configuration will be treated as a template; the <tt>$PATH_CERTIFICATE</tt>, <tt>$PATH_HTPASSWD</tt>, and <tt>$PATH_KEY</tt> tokens will be populated with the absolute paths provided by the [git_certs](#git_certs) and [git_htpasswd](#git_htpasswd) fixtures, as appropriate.
## <a name="markers"></a>Markers

### pytest.mark.create_repo

This marker specifies the GIT repository(ies) that should be initialized within the GIT service(s) prior to testing. It can ...

... decorate individual tests:

```python
import pytest
from pytest_docker_git_fixtures import GITSecure  # Optional, for typing

@pytest.mark.create_repo("test_git_secure")
def test_git_secure(git_secure: GITSecure):
	...
```

... be specified in the `pytestmark` list at the module level:

```python
#!/usr/bin/env python

import pytest

pytestmark = [pytest.mark.create_repo("test_generic_repo")]

...
```

... or be provided via the corresponding `--create-repo` command-line argument:

```bash
python -m pytest --create-repo repo0 --create-repo repo1 --create-repo repo2,repo3 ...
```

This marker supports being specified multiple times, and removes duplicate repository names (see [Limitations](#limitations) below).

A helper function, `get_created_repos`, is included for test scenarios that  wish to inspect the maker directly:

```python
import pytest
from pytest_docker_git_fixtures import GITSecure, get_created_repos

@pytest.mark.create_repo("test_git_secure")
def test_git_secure(git_secure: GITSecure, request):
    name = get_created_repos(request)[0]
```

### pytest.mark.mirror_repo

Similarly to create_repo, this marker specifies the GIT repository(ies) that should be replicated to the GIT service(s) prior to testing.

Likewise, there is a `get_mirrored_repos` helper function.

## <a name="enumerated_fixtures"></a>Enumerated Fixtures

It is possible to instantiate multiple GIT instances using the corresponding enumerated fixtures. All [fixtures](#fixtures) listed above have _*_list_ (e.g. `git_secure` -> `git_secure_list`) versions that will return enumerated lists of corresponding data type.

For example:

```python
import requests
from typing import List  # Optional, for typing
from pytest_docker_git_fixtures import GITSecure  # Optional, for typing

def test_git_secure_list(git_secure_list: List[GITSecure]):
    for git_secure in git_secure_list:
        # Default listener ...
        response = requests.get(
            f"https://{git_secure.endpoint}/",
            headers=git_secure.auth_header,
            verify=str(git_secure.cacerts),
        )
        assert response.status_code == 200
        assert response.content == b"pytest-docker-git-fixtures-docker\n"
```

It is possible to use both singular and enumerated fixtures within the same test context; however, the same values will be returned for the singular fixture as the first enumerated list value (i.e. git_secure == git_secure_list[0]). To avoid complications with lower layers, mainly docker-compose, and to allow for this interchangeability, caching is used internally.

By default, the scale factor of the enumerated instances is set to one (n=1). This value can be changed by overriding the `pdgf_scale_factor` fixture, as follows:

```python
import pytest

@pytest.fixture(scope="session")
def pdgf_scale_factor() -> int:
    return 4
```

This fixture will be used to scale both the insecure and secure GIT SCMs.

## <a name="limitations"></a>Limitations

1. All the fixtures provided by this package are <tt>session</tt> scoped; and will only be executed once per test execution.
2. The `create_repo`, and `mirror_repo` markers are processed as part of the `git_insecure` and `git_secure` fixtures. As such:
  * _all_ markers will be aggregated during initialization of the session, and processed prior test execution.
  * Initialized and mirror repositories will be applied to both the insecure and secure GIT SCMs, if both are instantiated.
3. At most 10 insecure and 10 secure GIT SCMs are supported using the embedded docker compose.
4. It is not currently possible to specify into which enumerated SCM instances repositories should be applied. As such, and for backwards compatibility, they will only be applied into the first instance of each of the insecure and secure GIT SCMs.

## Development

[Source Control](https://github.com/crashvb/pytest-docker-git-fixtures)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/crashvb/pytest-docker-git-fixtures",
    "name": "pytest-docker-git-fixtures",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "docker fixtures git pytest scm",
    "author": "Richard Davis",
    "author_email": "crashvb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ff/15/6e2b0ea195eb36a2a5ca36511defad5f4ccc08bf91e7c206c8ef6422d424/pytest_docker_git_fixtures-1.0.0.tar.gz",
    "platform": null,
    "description": "# pytest-docker-git-fixtures\n\n[![pypi version](https://img.shields.io/pypi/v/pytest-docker-git-fixtures.svg)](https://pypi.org/project/pytest-docker-git-fixtures)\n[![build status](https://github.com/crashvb/pytest-docker-git-fixtures/actions/workflows/main.yml/badge.svg)](https://github.com/crashvb/pytest-docker-git-fixtures/actions)\n[![coverage status](https://coveralls.io/repos/github/crashvb/pytest-docker-git-fixtures/badge.svg)](https://coveralls.io/github/crashvb/pytest-docker-git-fixtures)\n[![python versions](https://img.shields.io/pypi/pyversions/pytest-docker-git-fixtures.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/pytest-docker-git-fixtures)\n[![linting](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)\n[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![license](https://img.shields.io/github/license/crashvb/pytest-docker-git-fixtures.svg)](https://github.com/crashvb/pytest-docker-git-fixtures/blob/master/LICENSE.md)\n\n## Overview\n\nPytest fixtures to instantiate and populated local GIT SCMs, using [lovely-pytest-docker](https://pypi.org/project/lovely-pytest-docker), for testing.\n\n## Getting Started\n\nUpdate <tt>setup.py</tt> to include:\n\n```python\nfrom distutils.core import setup\n\nsetup(\n\ttests_require=[\"pytest-docker-git-fixtures\"]\n)\n```\n\nAll fixtures should be automatically included via the <tt>pytest11</tt> entry point.\n```python\nimport pytest\nimport subprocess\nfrom pathlib import Path\nfrom pytest_docker_git_fixtures import GITInsecure, GITSecure  # Optional, for typing\n\n@pytest.mark.create_repo(\"test_git_secure\")\n@pytest.mark.mirror_repo(\"https://github.com/crashvb/shim-bind.git\")\ndef test_git_secure(git_secure: GITSecure, tmp_path: Path):\n    uri = f\"https://{git_secure.endpoint}/secure/shim-bind.git\"\n    path = tmp_path.joinpath(\"local-clone\")\n    subprocess.run(\n        [\"git\", \"clone\", uri, str(path)],\n        check=True,\n        cwd=str(tmp_path),\n        stderr=subprocess.STDOUT,\n    )\n    assert path.joinpath(\"README.md\").exists()\n\n@pytest.mark.create_repo(\"test_git_insecure\")\ndef test_git_insecure(git_insecure: GITInsecure, tmp_path: Path):\n    uri = f\"https://{git_insecure.endpoint}/insecure/test_git_insecure.git\"\n    path = tmp_path.joinpath(\"local-clone\")\n    subprocess.run(\n        [\"git\", \"clone\", uri, str(path)],\n        check=True,\n        cwd=str(tmp_path),\n        stderr=subprocess.STDOUT,\n    )\n    assert path.exists()\n```\n\nThe `create_repo` and `mirror_repo` marks can optionally be added to stage repositories in the GIT prior to testing. See [Markers](#markers) for details.\n\n## Installation\n### From [pypi.org](https://pypi.org/project/pytest-docker-git-fixtures/)\n\n```\n$ pip install pytest_git_fixtures\n```\n\n### From source code\n\n```bash\n$ git clone https://github.com/crashvb/pytest-docker-git-fixtures\n$ cd pytest-docker-git-fixtures\n$ virtualenv env\n$ source env/bin/activate\n$ python -m pip install --editable .[dev]\n```\n\n## <a name=\"fixtures\"></a>Fixtures\n\n### <a name=\"git_auth_header\"></a> git_auth_header\n\nRetrieves an HTTP basic authentication header that is populated with credentials that can access the secure GIT service. The credentials are retrieved from the [git_password](#git_password) and [git_username](#git_username) fixtures.\n\n### <a name=\"git_cacerts\"></a> git_cacerts\n\nLocates a user-defined CA trust store (<tt>tests/cacerts</tt>) to use to verify connections to the secure GIT service. If one cannot be located, a temporary trust store is created containing certificates from <tt>certifi</tt> and the [git_certs](#git_certs) fixture. This fixture is used to instantiate the secure GIT service.\n\n### <a name=\"git_certs\"></a> git_certs\n\nReturns the paths of the self-signed certificate authority certificate, certificate, and private key that are used by the secure GIT service. This fixture is used to instantiate the secure GIT service.\n\n#### NamedTuple Fields\n\nThe following fields are defined in the tuple provided by this fixture:\n\n* **ca_certificate** - Path to the self-signed certificate authority certificate.\n* **ca_private_key** - Path to the self-signed certificate authority private key.\n* **certificate** - Path to the certificate.\n* **private_key** - Path to the private key.\n\nTyping is provided by `pytest_git_fixtures.GITCerts`.\n\n### <a name=\"git_hwpasswd\"></a> git_htpasswd\n\nProvides the path to a htpasswd file that is used by the secure GIT service. If a user-defined htpasswd file (<tt>tests/htpasswd</tt>) can be located, it is used. Otherwise, a temporary htpasswd file is created using credentials from the [git_password](#git_password) and [git_username](#git_username) fixtures. This fixture is used to instantiate the secure GIT service.\n\n### <a name=\"git_insecure\"></a> git_insecure\n\nConfigures and instantiates a GIT without TLS or authentication.\n\n```python\nimport pytest\nimport subprocess\nfrom pathlib import Path\nfrom pytest_docker_git_fixtures import GITInsecure  # Optional, for typing\n\n@pytest.mark.create_repo(\"test_git_insecure\")\ndef test_git_insecure(git_insecure: GITInsecure, tmp_path: Path):\n    uri = f\"https://{git_insecure.endpoint}/insecure/test_git_insecure.git\"\n    path = tmp_path.joinpath(\"local-clone\")\n    subprocess.run(\n        [\"git\", \"clone\", uri, str(path)],\n        check=True,\n        cwd=str(tmp_path),\n        stderr=subprocess.STDOUT,\n    )\n    assert path.exists()\n```\n\n#### NamedTuple Fields\n\nThe following fields are defined in the tuple provided by this fixture:\n\n* **created_repos** - The list of created repositories.\n* **docker_compose** - Path to the fully instantiated docker-compose configuration.\n* **endpoint** - Endpoint of the insecure GIT service.\n* **endpoint_name** - Endpoint of the insecure GIT service, by service name.\n* **mirrored_repos** - The list of mirrored repositories.\n* **service_name** - Name of the service within the docker-compose configuration.\n\nTyping is provided by `pytest_git_fixtures.GITInsecure`.\n\n### <a name=\"git_password\"></a> git_password\n\nProvides a generated password to use for authentication to the secure GIT service.\n\n### <a name=\"git_secure\"></a> git_secure\n\nConfigures and instantiates a TLS enabled GIT with HTTP basic authorization.\n\n```python\nimport pytest\nimport subprocess\nfrom pathlib import Path\nfrom pytest_docker_git_fixtures import GITSecure  # Optional, for typing\n\n@pytest.mark.mirror_repo(\"https://github.com/crashvb/shim-bind.git\")\ndef test_git_secure(git_secure: GITSecure, tmp_path: Path):\n    uri = f\"https://{git_secure.endpoint}/secure/shim-bind.git\"\n    path = tmp_path.joinpath(\"local-clone\")\n    subprocess.run(\n        [\"git\", \"clone\", uri, str(path)],\n        check=True,\n        cwd=str(tmp_path),\n        stderr=subprocess.STDOUT,\n    )\n    assert path.joinpath(\"README.md\").exists()\n```\n\n#### NamedTuple Fields\n\nThe following fields are defined in the tuple provided by this fixture:\n\n* **auth_header** - from [git_auth_header](#git_auth_header).\n* **cacerts** - from [git_cacerts](#git_cacerts).\n* **certs** - from [git_certs](#git_certs).\n* **created_repos** - The list of created repositories.\n* **docker_compose** - Path to the fully instantiated docker-compose configuration.\n* **endpoint** - Endpoint of the secure GIT service.\n* **endpoint_name** - Endpoint of the secure GIT service, by service name.\n* **htpasswd** - from [git_htpasswd](#git_htpasswd)\n* **mirrored_repos** - The list of mirrored repositories.\n* **password** - from [git_password](#git_password).\n* **service_name** - Name of the service within the docker-compose configuration.\n* **ssl_context** - from [git_ssl_context](#git_ssl_context).\n* **username** - from [git_username](#git_username).\n\nTyping is provided by `pytest_git_fixtures.GITSecure`.\n\n### <a name=\"git_ssl_context\"></a> git_ssl_context\n\nProvides an SSL context containing the CA trust store from the  [git_cacerts](#git_cacerts) fixture.\n\n### <a name=\"git_username\"></a> git_username\n\nProvides a generated username to use for authentication to the secure GIT service.\n\n### <a name=\"pdgf_docker_compose_insecure\"></a> pdgf_docker_compose_insecure\n\nThis fixture uses the `docker_compose_files` fixture to locate a user-defined docker-compose configuration file (typically <tt>tests/docker-compose.yml</tt>) that contains the <tt>pytest-docker-git-insecure</tt> service. If one cannot be located, an embedded configuration is copied to a temporary location and returned. This fixture is used to instantiate the insecure GIT service.\n\n### <a name=\"pdgf_docker_compose_secure\"></a> docker_compose_secure\n\nThis fixture uses the `docker_compose_files` fixture to locate a user-defined docker-compose configuration file (typically <tt>tests/docker-compose.yml</tt>) that contains the <tt>pytest-docker-git-secure</tt> service. If one cannot be located, an embedded configuration is copied to a temporary location and returned. This fixture is used to instantiate the secure GIT service; however, unlike the configuration returned by the [pdgf_docker_compose_insecure](#pdgf_docker_compose_insecure) fixture, this configuration will be treated as a template; the <tt>$PATH_CERTIFICATE</tt>, <tt>$PATH_HTPASSWD</tt>, and <tt>$PATH_KEY</tt> tokens will be populated with the absolute paths provided by the [git_certs](#git_certs) and [git_htpasswd](#git_htpasswd) fixtures, as appropriate.\n## <a name=\"markers\"></a>Markers\n\n### pytest.mark.create_repo\n\nThis marker specifies the GIT repository(ies) that should be initialized within the GIT service(s) prior to testing. It can ...\n\n... decorate individual tests:\n\n```python\nimport pytest\nfrom pytest_docker_git_fixtures import GITSecure  # Optional, for typing\n\n@pytest.mark.create_repo(\"test_git_secure\")\ndef test_git_secure(git_secure: GITSecure):\n\t...\n```\n\n... be specified in the `pytestmark` list at the module level:\n\n```python\n#!/usr/bin/env python\n\nimport pytest\n\npytestmark = [pytest.mark.create_repo(\"test_generic_repo\")]\n\n...\n```\n\n... or be provided via the corresponding `--create-repo` command-line argument:\n\n```bash\npython -m pytest --create-repo repo0 --create-repo repo1 --create-repo repo2,repo3 ...\n```\n\nThis marker supports being specified multiple times, and removes duplicate repository names (see [Limitations](#limitations) below).\n\nA helper function, `get_created_repos`, is included for test scenarios that  wish to inspect the maker directly:\n\n```python\nimport pytest\nfrom pytest_docker_git_fixtures import GITSecure, get_created_repos\n\n@pytest.mark.create_repo(\"test_git_secure\")\ndef test_git_secure(git_secure: GITSecure, request):\n    name = get_created_repos(request)[0]\n```\n\n### pytest.mark.mirror_repo\n\nSimilarly to create_repo, this marker specifies the GIT repository(ies) that should be replicated to the GIT service(s) prior to testing.\n\nLikewise, there is a `get_mirrored_repos` helper function.\n\n## <a name=\"enumerated_fixtures\"></a>Enumerated Fixtures\n\nIt is possible to instantiate multiple GIT instances using the corresponding enumerated fixtures. All [fixtures](#fixtures) listed above have _*_list_ (e.g. `git_secure` -> `git_secure_list`) versions that will return enumerated lists of corresponding data type.\n\nFor example:\n\n```python\nimport requests\nfrom typing import List  # Optional, for typing\nfrom pytest_docker_git_fixtures import GITSecure  # Optional, for typing\n\ndef test_git_secure_list(git_secure_list: List[GITSecure]):\n    for git_secure in git_secure_list:\n        # Default listener ...\n        response = requests.get(\n            f\"https://{git_secure.endpoint}/\",\n            headers=git_secure.auth_header,\n            verify=str(git_secure.cacerts),\n        )\n        assert response.status_code == 200\n        assert response.content == b\"pytest-docker-git-fixtures-docker\\n\"\n```\n\nIt is possible to use both singular and enumerated fixtures within the same test context; however, the same values will be returned for the singular fixture as the first enumerated list value (i.e. git_secure == git_secure_list[0]). To avoid complications with lower layers, mainly docker-compose, and to allow for this interchangeability, caching is used internally.\n\nBy default, the scale factor of the enumerated instances is set to one (n=1). This value can be changed by overriding the `pdgf_scale_factor` fixture, as follows:\n\n```python\nimport pytest\n\n@pytest.fixture(scope=\"session\")\ndef pdgf_scale_factor() -> int:\n    return 4\n```\n\nThis fixture will be used to scale both the insecure and secure GIT SCMs.\n\n## <a name=\"limitations\"></a>Limitations\n\n1. All the fixtures provided by this package are <tt>session</tt> scoped; and will only be executed once per test execution.\n2. The `create_repo`, and `mirror_repo` markers are processed as part of the `git_insecure` and `git_secure` fixtures. As such:\n  * _all_ markers will be aggregated during initialization of the session, and processed prior test execution.\n  * Initialized and mirror repositories will be applied to both the insecure and secure GIT SCMs, if both are instantiated.\n3. At most 10 insecure and 10 secure GIT SCMs are supported using the embedded docker compose.\n4. It is not currently possible to specify into which enumerated SCM instances repositories should be applied. As such, and for backwards compatibility, they will only be applied into the first instance of each of the insecure and secure GIT SCMs.\n\n## Development\n\n[Source Control](https://github.com/crashvb/pytest-docker-git-fixtures)\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Pytest fixtures for testing with git scm.",
    "version": "1.0.0",
    "project_urls": {
        "Bug Reports": "https://github.com/crashvb/pytest-docker-git-fixtures/issues",
        "Homepage": "https://github.com/crashvb/pytest-docker-git-fixtures",
        "Source": "https://github.com/crashvb/pytest-docker-git-fixtures"
    },
    "split_keywords": [
        "docker",
        "fixtures",
        "git",
        "pytest",
        "scm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2e58e974780b528d2b451e15f355394ecb1749450af298470fa7260994d0cb26",
                "md5": "ccf10d53ea0c51bb6f9bb9c2a369d25c",
                "sha256": "fb9f0ba046376de81ce4e3a660d580158ac0a86e216ca6a8f1eb9edf4e4295ed"
            },
            "downloads": -1,
            "filename": "pytest_docker_git_fixtures-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ccf10d53ea0c51bb6f9bb9c2a369d25c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 24787,
            "upload_time": "2024-08-12T23:38:17",
            "upload_time_iso_8601": "2024-08-12T23:38:17.087408Z",
            "url": "https://files.pythonhosted.org/packages/2e/58/e974780b528d2b451e15f355394ecb1749450af298470fa7260994d0cb26/pytest_docker_git_fixtures-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff156e2b0ea195eb36a2a5ca36511defad5f4ccc08bf91e7c206c8ef6422d424",
                "md5": "042219fb5d97a1147a6b0ce61c7e3908",
                "sha256": "fd568b5f28698ecc8e65931ef8206e168855f7178a9e6e3a61f2daa2ee8da7cb"
            },
            "downloads": -1,
            "filename": "pytest_docker_git_fixtures-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "042219fb5d97a1147a6b0ce61c7e3908",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 24446,
            "upload_time": "2024-08-12T23:38:18",
            "upload_time_iso_8601": "2024-08-12T23:38:18.537182Z",
            "url": "https://files.pythonhosted.org/packages/ff/15/6e2b0ea195eb36a2a5ca36511defad5f4ccc08bf91e7c206c8ef6422d424/pytest_docker_git_fixtures-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-12 23:38:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crashvb",
    "github_project": "pytest-docker-git-fixtures",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytest-docker-git-fixtures"
}
        
Elapsed time: 0.33649s