Metadata-Version: 2.4
Name: autumn-yaml-test
Version: 1.0.0
Summary: A convention-based YAML API testing library for Python & FastAPI
Author: Antigravity Team
Project-URL: Homepage, https://github.com/andinolabs-tech/autumn-py
Project-URL: Repository, https://github.com/andinolabs-tech/autumn-py
Project-URL: Issues, https://github.com/andinolabs-tech/autumn-py/issues
Keywords: pytest,yaml,api-testing,fastapi,httpx
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pytest>=7.0.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: faker>=18.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: pytz>=2023.3

# Autumn-Py - Convention-Based YAML API Testing Framework for Python & FastAPI

Autumn-Py is a convention-based API automation testing framework designed to streamline and simplify the testing process, inspired by the Java `Autumn` library.

By integrating directly with **pytest**, Autumn-Py allows you to run clutter-free API tests based on YAML files, eliminating repetitive test code. It supports testing local FastAPI applications (using `httpx.Client(app=...)` under the hood) as well as external REST services.

## Features

- **No Boilerplate Code Required**: Write tests in YAML, not Python.
- **Convention-Based**: Follows standard patterns, zero configuration to start.
- **pytest Integration**: Discovered and run automatically by `pytest`.
- **FastAPI / Local Testing**: Route requests directly against your FastAPI app via the `autumn_app` fixture.
- **Arrange-Act-Assert Support**: Set up preconditions, run the main API call, and assert expectations.
- **Rich Data Generation**: Dynamic random names, emails, UUIDs, datetimes, sentences, and more using `faker`.
- **Placeholder Chaining**: Reference responses of previous arrange steps in URLs, headers, and request bodies.
- **Flexible JSON Assertions**: Easily match dynamic fields with matchers (e.g. UUID, datetime, regex, types) and ignore extra fields if needed.
- **Conditional Skip Scheduling**: Restrict test execution by day or time of day.

## Installation

```bash
pip install autumn-yaml-test
```

## Quick Start

1. **Define your test yml files** (e.g. under `tests/`):

```yaml
# tests/get_user.yml
name: Get User by ID
act:
  url: "https://jsonplaceholder.typicode.com/users/1"
  method: GET

asserts:
  status: 200
  body:
    id: 1
    name: "Leanne Graham"
    email: "${json-unit.matches:regex}[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
```

2. **Run your tests**:

```bash
pytest
```
That's it! The plugin discovers all `.yml`/`.yaml` files containing an `act:` block and executes them dynamically.

## Testing a Local FastAPI App

To test your local FastAPI application without running a separate server, define an `autumn_app` fixture in your `conftest.py`:

```python
# tests/conftest.py
import pytest
from my_app import app

@pytest.fixture
def autumn_app():
    return app
```

With `autumn_app` defined, Autumn-Py routes all requests in your YAML files directly through FastAPI's `TestClient` routing.

## YAML Specification

Refer to the examples under `tests/resources/` for a full showcase of features including:
- Data generation: `${generate:name}`, `${generate:email}`, `${generate:datetime:1minutesAgo}`, `${generate:uuid}`.
- Arrange steps: wait steps (`type: wait`), API dependencies (`type: api`), and `saveResponseAs`.
- Flexible asserts: ignore extra fields using `customization`.
