These instructions where extracted from Emily Bache GitHub. The link to the original instructions can be found in the link bellow.
This is exercise is the starting point of an exercise extracted from the book "Refactoring" by Martin Fowler.
The code is a program fo calculating the customer statement for a troop of theatrical players. If you go to see a play you can earn volume credits that gives you discounts on future plays.
The idea of the kata is to go through the code and refactor it step by step to improve readability and maintainability. Originally, the exercise in the book didn't have tests, but in this version we are working with python approval testing library.
There are some test data:
- plays.json: contains the plays that the troop can perform
- invoice.json: contains details recent performances with information about the play and the audience
- new_plays.json: contains new plays that the program do not support
- invoice_new_plays.json:
The main objective is to:
- Practice refactoring legacy code
- Identify code smells
- Try to apply object calisthenics
The project can be configured with pdm
.
- Install pdm:
pip install pdm
- Install required python version:
pdm python install 3.12
- Create a virtual environment and install dependencies:
It will create the .venv folder inside the project automatically.
pdm install
- You can activate the virtual environment manually running
source .venv/bin/activate
on Unix systems orsource .venv/Scripts/activate
on Windows.
To run the tests, execute one of the following commands:
pytest
or
pdm run pytest