-
Notifications
You must be signed in to change notification settings - Fork 13
Update user #300
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
Update user #300
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ |
src/code42cli/cmds/users.py
Outdated
@sdk_options() | ||
def bulk_update(state, csv_rows, format): | ||
"""Update a list of users from the provided CSV.""" | ||
csv_rows[0]["updated"] = False |
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.
Why do we need this line csv_rows[0]["updated"] = False
?
What happens if someone passes in a csv with no rows, does this through some IndexError?
^ if that is the case, and this is needed, we should check the length first and fail early with a better error
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 is to add the column, for some reason if we don't add it beforehand, the addition during handle_row wasn't working properly. I copied this approach from how devices bulk deactivate
does it.
The CSV is validated by read_csv(), which will raise an error if the CSV does not contain the proper rows.
In |
def test_update_user_calls_update_user_with_correct_parameters( | ||
runner, cli_state, update_user_success | ||
): | ||
command = ["users", "update", "--user-id", "12345", "--email", "test_email"] |
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.
Can you include all the args here so the test confirms they all get passed to the right spot?
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 wanted to test also that it properly passed None
where no argument was given (since we don't want the method to accidentally update all unchanged fields to blank values). I've added additional tests to validate that all parameters are passed properly.
…dated" column in devices bulk update; more comprehensive 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.
In
code42cli.click_ext.groups.py
, can you importPy42UsernameMustBeEmailError
from py42 (gets raised duringupdate_user()
) and add it to the exception list caught in lines 59-69?
I've added 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.
Do you mind also changing cmd/devices/.py
where it says
csv_rows[0]["deactivated"] = False
to
csv_rows[0]["deactivated"] = "False"
that would be helpful.
This PR looks good!
…deactivated" column
Sure, I'll do that now. |
Description of Change
This change adds a method
code42 users update
to update a single user, and the corresponding bulk methodcode42 users bulk update
It partially addresses (but does not fully address) issue #259
Testing Procedure
PR Checklist