-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
32 implementation of cli interface #46
base: develop
Are you sure you want to change the base?
Conversation
Hello @LFK01 Could you add pytest tests following this guide? https://click.palletsprojects.com/en/8.1.x/testing/ You can check for reference the existing tests in |
Hi @ggbaro , |
src/swapanything/cli.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. I just have a request about formatting. Can you execute ruff check --fix
? So we can auto-fix indentation and stuff like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've run the command but I didn't see any change with respect to indentation or other modifications
runner = CliRunner() | ||
|
||
# not using runner.isolated_filesystem() because it would the CWD and the input csv wouldn't be found, pytest tmp dir is more effective | ||
input_csv_path = os.path.join('tests', 'unit_test', 'data', 'faker_availabilities.csv') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a path relative to the __file__
special variable (the path of the current file). This way the execution is deterministic (does not depend on where you launch the pytest command)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually in my projects I use a file like consts.py or utils.py where I define file paths starting from that file such that it will never be moved and all the other files in the repository use those constants as a reference.
I implemented the change as you requested but let me know if you want to have a more global approach.
The command execution requires the package installation which can be obtained with the following command inside the cloned repository directory:
pip install -e .
The
-e
flag allows the developer to change the code and observe the changes without reinstalling the package..
is the cloned repository directory where pip will search for thepyproject.toml
file.You can test the CLI with:
swapanything tests/unit_test/data/faker_availabilities.csv output.csv --headers --index-col --subject-col "Nome e Cognome" --slot-col "Availabilities"
It should print the selected matches in the file output.csv. Remember to delete or to exclude the file output.csv when committing to the branch or change its path to another position.