The purpose of this repository is mainly to explore pytest. Tests can be found in tests.
To ensure code quality, this repository leverages the capabilities of pre-commit. If you're curious about pre-commit and want to explore its features further, I recommend checking out this other repository: 101_pre-commit
Content | Description |
---|---|
src | ETL script, input, and output datasets serving as a foundation for writing focused tests. |
tests | Tests - Go to tests/README.md for more details on what's covered by this repo. |
tests/unit | Unit tests |
tests/integration | Integration tests |
github_ci | Workflow that runs static analysis, the script, the tests and generates test reports and test coverage report |
To run locally, you will need Python 3.11 or newer installed in your local environment. Then, just install the dependencies and execute the main.py
file:
Create a virtual environment:
python3 -m venv .venv
Activate local environment:
source .venv/bin/activate
Install dependencies:
pip install -r requirements.txt
Install git hooks (optional, do it only if you wanna use pre-commit):
pre-commit install
Run script:
python3 src/main.py
Run tests:
pytest -v tests
Run test coverage command to generate report locally (it will be generated by the GitHub Actions workflow automatically and it will be stored as an artifact. You can look for it there instead of generating it locally, if you prefer.):
pytest --cov --cov-report=html
If you installed git hooks but wanna skip pre-commit checks, run:
git commit -m"message" --no-verify
Go to the project in Github and click in Actions
(top left):
Select the last workflow run:
Once it's finished, you should be able to see the artifacts it generated (bottom):
Download it, unzip it. To see the Test Coverage Report, click on coverage-report.html
and open index.html
You should see something like this:
To expand and see more details, click in src/main.py
: