refactoring (#13)

* general project refactoring

* various small improvements

* improve imap fixture with helper functions and typing

* add wordpress send email setup

* add wordpress receive email test

* add various documentation

Reviewed-on: local-it-infrastructure/e2e_tests#13
Co-authored-by: Daniel <d.brummerloh@gmail.com>
Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
Daniel 2023-12-08 18:17:31 +01:00 committed by dan
parent 41a042f07d
commit d1ff1183a5
29 changed files with 323 additions and 175 deletions

View file

@ -2,19 +2,19 @@
Pytest-Abra is an installable python package design to test instances created with [abra](https://docs.coopcloud.tech/abra/). After installation, you will have two things:
- `abratest` CLI command
- `abratest` CLI command. *Used to initialize the testing.*
- `pytest-abra` Pytest plugin
- `pytest-abra` Pytest plugin. *Automatically loads custom fixtures in any pytest (see `pytest_abra/custom_fixtures.py`)*
## CLI (abratest)
## CLI (`abratest`)
The easiest way to call abratest is via the helper script in `main.py`. You can also directly call abratest via terminal, but you will have to make sure that the requirements below are met. To do that, you can call `abratest` with:
`abratest` can be called via terminal:
```bash
abratest [arguments]
```
The cli command abratest has 3 **required arguments**:
To run successfully, very specific arguments are required. The easiest way to use abratest is with the helper script in `main.py`. Of yourse you can implement a similar helper script in the language of your liking. The cli command `abratest` has 3 **required arguments**:
- `--env_paths`: list of the .env files used in the test
- `--recipes_dir`: directory of all available abra recipes
@ -66,12 +66,20 @@ DIR recipes_dir [contains abra recipes]
└── [pytest_files]
```
The class `RunnerWordpress` will be automatically imported by `importlib`, which is equivalent to
The class `RunnerWordpress` will be automatically imported using `importlib` library, which is equivalent to the code below. Note that `recipes_dir` will be added to sys.path automatically for the import to work and that every `Runner` class matching `recipes_dir.rglob("*/runner*.py")` will be imported.
```python
from wordpress.tests_wordpress.runner_wordpress import RunnerWordpress
```
### output_dir [string]
Path to the directory where all test outputs are stored (test report, tracebacks, playwright traces etc.)
```
abratest --output_dir /path/to/output
```
# Usage
To use pytest-abra, follow these steps:
@ -108,7 +116,7 @@ Run the script with
python main.py
```
# 2.2 Run with Docker
## 2.2 Run with Docker
```bash
docker compose build # build the image
@ -128,12 +136,13 @@ Force rebuild without cache
docker-compose build --no-cache
```
## Codegen
## Playwright Debug & Codegen
Use playwright codegen to create code for new testes easily https://playwright.dev/python/docs/codegen
Use playwright debug mode or codegen to create testing code easily by recording browser actions https://playwright.dev/python/docs/codegen
```bash
playwright codegen demo.playwright.dev/todomvc
abratest --debug # launch your tests in debug mode
playwright codegen demo.playwright.dev/todomvc # visit given url in codegen mode
```
## Development