-
Notifications
You must be signed in to change notification settings - Fork 96
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
Added checkbox locked choices feature #327
Conversation
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.
@NivEz thanks a lot for your contribution. Please check out tests in tests
folder, we are committed to delivering a high quality code and having unit, integration and acceptance tests are a way to ensure that. Also, I see that current code is failing pre-commit checks, you can run it locally with pre-commit install
and then pre-commit run --all-files
. You can find a bit more details in our contributing guide.
Hey, Thanks |
The coverage/patch displays the coverage of your added lines, which is currently 83.3%. This means that not all of the lines added by you are coverd by allready existing tests. This is to be expected, as you added branches to the code (new To increase the coverage, simply add the missing tests.
|
for a detailed breakdown, see the codecov webpage. As you can see there, your added There is also a existing problem further up, where a line is not covered at all (maked red), you can ignore it but we missed it on a code review which is exacly what this test are here to prevent as much as possible |
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 think it should be visually more obvious that choises are locked. For example by changing the color (maybe a gray?)
Good point, added gray color |
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.
Just a thought: should it really be assumed that locked choise must be selected? wouldn't it also make senese to lock choises as they are and use the default
setting to choose if they are selected or not. As it stands now, the functionalaty overlapps and its not possible to display options that are no longer choosable based on previous inputs (I mean you could just remove these options all together, but if we want to lock stuff this is a valid usecase??)
also it would be great to make the commits more atomic and have less small commits that just fix stuff from a previous commit. You can do this by resetting to a previous commit and appending to it, than cherry pick the other commits. You can force-push it to your branch and the PR will update.
This is not mandatory and just a preference of mine to have clean commits that contain all changes belonging to a feature. For example: one commit for the feature, one commit for the tests and one commit for the documentations
|
||
def test_locked_option(self): | ||
self.sut.send(key.SPACE) | ||
self.sut.send(key.LEFT) |
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.
Its a good idea to test for both keys to select a option.
But in this case the test would actually succseed even if the locking code didn't work, as it deselects and than imediatly selects againt. So please seperate this into two seperate tests
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.
Seprated into two tests
@@ -324,3 +324,59 @@ def test_double_invert_all(self): | |||
result = sut.render(question) | |||
|
|||
assert result == [] | |||
|
|||
def test_unselect_locked(self): | |||
stdin_array = [key.SPACE, key.LEFT, key.ENTER] |
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.
same as above
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.
Seprated into two tests as well
self.current = 0 | ||
|
||
def set_default_choices(self): |
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.
this function is named strangely. I assume you wanted to make its return type clear? (which changed in the meantime)
However like this its named as a Setter-Methode, which it is clearly not.
def set_default_choices(self): | |
def default_choices(self): |
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.
Renamed
I also just fixed the security issue on main, so please rebase |
1935044
to
fc055c1
Compare
@Cube707 Thanks for reviewing :) |
@NivEz sorry it took so long, but I finally had the time to look at this and merge it. Hope it can still be helpfull to you |
Checkbox locked choices feature:
This feature gives the option lock some choices.
Locked choices cannot be removed (with space or left button) and they are merged with the default choices, so they appear as checked choices.
This is similar to giving choices to the user which must be chosen in order to continue with the process (like user agreement). The only option not to choose the locked option is to break the program.
This is useful if you want to make it clear that some choice/s out of the list must be chosen in order to continue.
BTW this package is awesome and I use it for installation tool that I might publish soon (created this PR because I needed this feature in my project).