semvec/pypi-packages huggingface dataset:
pytest-power 1.0.1
pytest plugin with powerful fixtures
License: MIT
Requires Python: >=3.5,<4.0

# pytest-power

![python](https://github.com/NL-ix/pytest-power/workflows/python/badge.svg)
[![PyPI](https://img.shields.io/pypi/v/pytest-power?style=flat)](https://pypi.org/project/pytest-power/)

Adds a number of shorthands for fixtures and other helpers for easier testing:

- patch.object
- patch.init
- patch.many
- patch.everything

You can instal pytest-power with pip:

```sh
pip install pytest-power
```

## Usage

### patch.object

A shorthand for pytest-mock's `mocker.patch.object`


```python
from myapp import App

def test_app_run(patch):
  patch.object(App, 'run')
  App.run()
  assert App.run.call_count == 1
```

You can pass keywords arguments as usual:

```python
from myapp import App

def test_app_run(patch):
  patch.object(App, 'run', return_value='running')
  assert App.run() == 'running'
```


### patch.init

Makes patching `__init__` a bit simpler:


```python
from myapp import App

def test_app_init(patch):
  patch.init(App)
  app = App()
  assert isinstance(app, App)
```

Instances patched in this way do not have properties that are set in `__init__`,
so they have to be set again by hand.

Keyword arguments are passed to underlying `patch.object`, and autospec is
enabled by default.

Multiple classes can be passed too:

```python
patch.init(App, Cli)
```


### patch.many

A shorthand to patch many properties of the same object:

```python
from myapp import App

def test_app_run_called_by_run(patch):
  patch.many(App, ['run', 'called_by_run'])
  App.run()
  assert App.called_by_run.call_count == 1
```

Keyword arguments are again passed to underlying `patch.object`, and autospec
is enabled by default.

### patch.everything

A shorthand to patch every non-magic property. Useful when patch.many gets
too long!

```python
from myapp import App


def test_app_run_called_by_run(patch):
  patch.everything(App)
  App.run()
  assert App.called_by_run.call_count == 1
```

Supports forcing the exclusion of properties:

```python
from myapp import App


def test_app_run(patch, excludes=['run']):
  patch.everything(App)
  App.run()
  assert App.called_by_run.call_count == 1
```


And forcing the inclusion of properties:

```python
from myapp import App


def test_app_run(patch, includes=['__private__']):
  patch.everything(App)
  App.run()
  assert App.__private__.call_count == 1
```
FastAPI-CRUDRouter 0.2.1
A dynamic FastAPI router that automatically creates CRUD routes for your models
License: MIT
Requires Python: >=3.6
Keywords: fastapi,crud,restful,routing,generator

<p align="center">
  <img src="https://raw.githubusercontent.com/awtkns/fastapi-crudrouter/master/docs/assets/logo2.png" height="200" />
</p>
<p align="center">
  <em>âš¡ Create CRUD routes with lighting speed</em> âš¡</br>
  <sub>A dynamic FastAPI router that automatically creates CRUD routes for your models</sub>
</p>
<p align="center">
<img alt="Tests" src="https://github.com/awtkns/fastapi-crudrouter/workflows/Python%20application/badge.svg" />
<img alt="Docs" src="https://github.com/awtkns/fastapi-crudrouter/workflows/docs/badge.svg" />
  <a href="https://pypi.org/project/fastapi-crudrouter" target="_blank">
    <img src="https://img.shields.io/pypi/v/fastapi-crudrouter?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
</p>

---

**Documentation**: <a href="https://awtkns.github.io/fastapi-crudrouter" target="_blank">https://awtkns.github.io/fastapi-crudrouter</a>

**Source Code**: <a href="https://github.com/awtkns/fastapi-crudrouter" target="_blank">https://github.com/awtkns/fastapi-crudrouter</a>

---
Tired of rewriting the same generic CRUD routes? Need to rapidly prototype a feature for a presentation
or a hackathon? Thankfully, [fastapi-crudrouter](https://github.com/awtkns/fastapi-crudrouter) has your back. As an 
extension to the APIRouter included with [FastAPI](https://fastapi.tiangolo.com/), the FastAPI CRUDRouter will automatically
generate and document your CRUD routes for you, all you have to do is pass your model and maybe your database connection.

FastAPI-CRUDRouter is also **lighting fast**, well tested, and **production ready**.


## Installation
```bash
pip install fastapi-crudrouter
```

## Basic Usage
Below is a simple example of what the CRUDRouter can do. In just ten lines of code, you can generate all 
the crud routes you need for any model.  A full list of the routes generated can be found [here](./routing).

```python
from pydantic import BaseModel
from fastapi import FastAPI
from fastapi_crudrouter import MemoryCRUDRouter as CRUDRouter

class Potato(BaseModel):
    id: int
    color: str
    mass: float

app = FastAPI()
app.include_router(CRUDRouter(model=Potato))
```

## OpenAPI Support
By default, all routes generated by the CRUDRouter will be documented according to OpenAPI spec.

Below are the default routes created by the CRUDRouter shown in the generated OpenAPI documentation.

![OpenAPI Route Overview](https://raw.githubusercontent.com/awtkns/fastapi-crudrouter/master/docs/assets/RouteOverview.PNG)

The CRUDRouter is able to dynamically generate detailed documentation based on the models given to it.

![OpenAPI Route Detail](https://raw.githubusercontent.com/awtkns/fastapi-crudrouter/master/docs/assets/RouteDetail.PNG)

## Database Support
Currently, fastapi-crudrouter supports all database supported by SQLAlchemy.  Async and NonRelational database support will
be coming soon.