semvec/pypi-packages huggingface dataset:
cdk-integ-runner-cwd-fix 0.1.1
Fix the problem with CDK's integ-runner breaking the python path and current working directory.
License: MIT
Requires Python: >=3.8,<4.0
Keywords: cdk,aws-cdk,aws,testing,test

# CDK integ-runner CWD Fix

When running integ-test on python, the CWD is set to the directory which
contains your test file - not the directory which contains your cdk.json.

It also blows away the PYTHONPATH, so that no longer has your cdk project.

This means that your test file has no access to the stacks you create, and
you get a lot of ModuleNotFoundError when you try to import your stacks into
the test case.

It also breaks the lambda (and likely other) builds which rely on a path. So,
If you're using `Code.from_asset("./lambda")` you should start using
`Code.from_asset(f"{os.getcwd()}/lambda")` instead, after using this fix.

This is likely to be applicable to other constructs that rely on a relative path.

This is a workaround to fix the CWD and PYTHONPATH so that your test file
can import your stacks and run the integ tests.

## Usage

### Installation

``` bash
pip install cdk-integ-runner-cwd-fix
```


### In your code

Then, in your test file, add the following lines:

```python
from cdk_integ_runner_cwd_fix import fix_cwd

fix_cwd()

# You can now import your stack
from my_cdk_project.my_stack import MyStack

# And write your test code here
app = cdk.App()
stack = MyStack(app, "TestStack")

app.synth()
```

### Running tests

You'll need to set the project path in the environment variable `CDK_INTEG_RUNNER_CWD`:

The below will set it to your current directory - which is likely to be what you need:

```bash
export CDK_INTEG_RUNNER_CWD=$(pwd)
```

or to be explicit, or to set it to something other than the path you're currently in:

```bash
export CDK_INTEG_RUNNER_CWD=/path/to/your/cdk/project
```

Then, run your tests as usual:

```bash
integ-runner
```
pyfa-converter 1.0.5.0
Pydantic to fastapi model converter.
License: MIT
Requires Python: >=3.8

# pyfa-converter
Allows you to convert pydantic models for fastapi param models - query, form, header, cookie, body, etc.



### How to install?
`pip install pyfa_converter`

### How to simplify your life?
```python3
from datetime import datetime
from typing import Optional

from fastapi import FastAPI, UploadFile, File, Form
from pydantic import BaseModel, Field

from pyfa_converter import FormDepends, PyFaDepends

app = FastAPI()


class PostContractBodySchema(BaseModel):
    title: str = Field(..., description="Description title")
    date: Optional[datetime] = Field(
        None, description="Example: 2021-12-14T09:56:31.056Z"
    )


@app.post("/form-data-body")
async def example_foo_body_handler(
    data1: PostContractBodySchema = PyFaDepends(model=PostContractBodySchema, _type=Form),
    document: UploadFile = File(...),
):
    return {"title": data.title, "date": data.date, "file_name": document.filename}
```

---

### What do I need to do?
```python3
from pyfa_converter import PyFaDepends, FormDepends, QueryDepends
from fastapi import Header, Form
...

async def foo(data: MyCustomModel = PyFaDepends(MyCustomModel, _type=Header)): ...
async def foo(data: MyCustomModel = PyFaDepends(MyCustomModel, _type=Form)): ...

async def foo(data: MyCustomModel = FormDepends(MyCustomModel)): ...
async def foo(data: MyCustomModel = QueryDepends(MyCustomModel)): ...
```

---

If you want to accept a file on an endpoint, then the content-type for that endpoint changes from application/json to www-form-data.

FastAPI does not know how to override the pydantic schema so that parameters are passed as form.
Even if you do

`foo: CustomPydanticModel = Depends()`
all model attributes will be passed as query, but we want them to become body, that's what this library exists for.

### Usually you use something along the lines of:
![image](https://user-images.githubusercontent.com/64792903/161484700-642e3d0e-242f-49f6-82e8-45c5e912a2c2.png)

But, if we accept a lot of fields, then the function becomes very large (the number of attributes for the endpoint increases and it does not look very good).

Thanks to this library, it is possible to force the conversion of Field fields into fields of FastAPI Form with full preservation of all attributes (alias, gt, te, description, title, example and more...)