Skip to content
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

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

LFK01
Copy link
Collaborator

@LFK01 LFK01 commented Mar 20, 2024

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 the pyproject.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.

@LFK01 LFK01 added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 20, 2024
@LFK01 LFK01 requested a review from ggbaro March 20, 2024 19:58
@LFK01 LFK01 self-assigned this Mar 20, 2024
@ggbaro
Copy link
Contributor

ggbaro commented Mar 24, 2024

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 tests/unit_test/swapanything_test

@LFK01
Copy link
Collaborator Author

LFK01 commented May 13, 2024

Hi @ggbaro ,
I implemented the tests, let me know if everything adds up.

Copy link
Contributor

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

Copy link
Collaborator Author

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')
Copy link
Contributor

@ggbaro ggbaro May 14, 2024

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)

Copy link
Collaborator Author

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.

tests/unit_test/swapanything_test/test_cli.py Outdated Show resolved Hide resolved
tests/unit_test/swapanything_test/test_cli.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants