Metadata-Version: 2.3
Name: ucam-protobuf-testing
Version: 0.2.0
Summary: Testing support library for python protobuf projects
License: MIT
Author: University of Cambridge Information Services
Author-email: devops-wilson@uis.cam.ac.uk
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: factory-boy (>=3.3.3,<4.0.0)
Project-URL: Repository, https://gitlab.developers.cam.ac.uk/uis/devops/lib/ucam-protobuf-testing-python
Description-Content-Type: text/markdown

# UCam Protobuf Testing Library

This project contains a support library to enable projects using python code
autogenerated from protobuf files to be more easily tested.

Currently it contains an auto-factory function supporting creating
[`factory-boy`](https://factoryboy.readthedocs.io/en/stable/introduction.html)
factories from
[`betterproto`](https://github.com/danielgtaylor/python-betterproto)
generated python code.

## Usage

Install the library via pip:

```console
pip install ucam-protobuf-testing
```

Then create a factory from a dataclass or betterproto message:

```python
@dataclass
class A:
    a_text: str
    integer: int
    value: float


class MyEnum(Enum):
    option1 = 1
    option2 = 2


@dataclass
class B:
    related: A
    an_enum: MyEnum
    list_of_str: list[str]


AFactory = auto_factory(A)
BFactory = auto_factory(B)
```

## Local Development

Install poetry via:

```console
pipx install poetry
pipx inject poetry poethepoet[poetry_plugin]
```

Install dependencies via:

```console
poetry install
```

Build the library via:

```console
poetry build
```

Run the tests via:

```console
poetry poe tox
```

### Dependencies

To add a new dependency for the library:

```console
poetry add {dependency}
```

To add a new development-time dependency, used only during testing:

```console
poetry add -G dev {dependency}
```

To remove a dependency which is no longer needed:

```console
poetry remove {dependency}
```

## CI configuration

The project is configured with Gitlab AutoDevOps via Gitlab CI using the .gitlab-ci.yml file.

