-
Notifications
You must be signed in to change notification settings - Fork 13
Users command: option to report on legal hold membership #290
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
Changes from 10 commits
12e9478
2dbc0c4
002c605
f12fe45
51367c0
c9b3987
7d403d3
ac50108
9a2f41d
c5bda56
aaff514
b53ee2b
0d6d108
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,42 @@ | |
} | ||
] | ||
} | ||
TEST_MATTER_RESPONSE = { | ||
"legalHolds": [ | ||
{"legalHoldUid": "123456789", "name": "Legal Hold #1", "active": True}, | ||
{"legalHoldUid": "987654321", "name": "Legal Hold #2", "active": True}, | ||
] | ||
} | ||
TEST_CUSTODIANS_RESPONSE = { | ||
"legalHoldMemberships": [ | ||
{ | ||
"legalHoldMembershipUid": "99999", | ||
"active": True, | ||
"creationDate": "2020-07-16T08:50:23.405Z", | ||
"legalHold": {"legalHoldUid": "123456789", "name": "Legal Hold #1"}, | ||
"user": { | ||
"userUid": "911162111513111325", | ||
"username": "[email protected]", | ||
"email": "[email protected]", | ||
"userExtRef": None, | ||
}, | ||
}, | ||
{ | ||
"legalHoldMembershipUid": "11111", | ||
"active": True, | ||
"creationDate": "2020-07-16T08:50:23.405Z", | ||
"legalHold": {"legalHoldUid": "987654321", "name": "Legal Hold #2"}, | ||
"user": { | ||
"userUid": "911162111513111325", | ||
"username": "[email protected]", | ||
"email": "[email protected]", | ||
"userExtRef": None, | ||
}, | ||
}, | ||
] | ||
} | ||
TEST_EMPTY_CUSTODIANS_RESPONSE = {"legalHoldMemberships": []} | ||
TEST_EMPTY_MATTERS_RESPONSE = {"legalHolds": []} | ||
TEST_EMPTY_USERS_RESPONSE = {"users": []} | ||
TEST_USERNAME = TEST_USERS_RESPONSE["users"][0]["username"] | ||
TEST_USER_ID = TEST_USERS_RESPONSE["users"][0]["userId"] | ||
|
@@ -68,10 +104,6 @@ | |
} | ||
|
||
|
||
def get_all_users_generator(): | ||
yield TEST_USERS_RESPONSE | ||
|
||
|
||
@pytest.fixture | ||
def update_user_response(mocker): | ||
return create_mock_response(mocker) | ||
|
@@ -103,7 +135,10 @@ def get_org_success(cli_state, get_org_response): | |
|
||
|
||
@pytest.fixture | ||
def get_all_users_success(cli_state): | ||
def get_all_users_success(mocker, cli_state): | ||
def get_all_users_generator(): | ||
yield create_mock_response(mocker, data=TEST_USERS_RESPONSE) | ||
|
||
cli_state.sdk.users.get_all.return_value = get_all_users_generator() | ||
|
||
|
||
|
@@ -120,6 +155,42 @@ def get_user_id_failure(mocker, cli_state): | |
) | ||
|
||
|
||
@pytest.fixture | ||
def get_custodian_failure(mocker, cli_state): | ||
def empty_custodian_list_generator(): | ||
yield TEST_EMPTY_CUSTODIANS_RESPONSE | ||
|
||
cli_state.sdk.legalhold.get_all_matter_custodians.return_value = ( | ||
empty_custodian_list_generator() | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def get_matter_failure(cli_state): | ||
def empty_matter_list_generator(): | ||
yield TEST_EMPTY_MATTERS_RESPONSE | ||
|
||
cli_state.sdk.legalhold.get_all_matters.return_value = empty_matter_list_generator() | ||
|
||
|
||
@pytest.fixture | ||
def get_all_matter_success(mocker, cli_state): | ||
def matter_list_generator(): | ||
yield create_mock_response(mocker, data=TEST_MATTER_RESPONSE) | ||
|
||
cli_state.sdk.legalhold.get_all_matters.return_value = matter_list_generator() | ||
|
||
|
||
@pytest.fixture | ||
def get_all_custodian_success(mocker, cli_state): | ||
def custodian_list_generator(): | ||
yield create_mock_response(mocker, data=TEST_CUSTODIANS_RESPONSE) | ||
|
||
cli_state.sdk.legalhold.get_all_matter_custodians.return_value = ( | ||
custodian_list_generator() | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def get_available_roles_success(cli_state, get_available_roles_response): | ||
cli_state.sdk.users.get_available_roles.return_value = get_available_roles_response | ||
|
@@ -241,6 +312,66 @@ def test_list_users_when_given_excluding_active_and_inactive_uses_active_equals_ | |
) | ||
|
||
|
||
def test_list_legal_hold_flag_reports_none_for_users_not_on_legal_hold( | ||
runner, | ||
cli_state, | ||
get_all_users_success, | ||
get_custodian_failure, | ||
get_all_matter_success, | ||
): | ||
result = runner.invoke( | ||
cli, | ||
["users", "list", "--include-legal-hold-membership", "-f", "CSV"], | ||
obj=cli_state, | ||
) | ||
|
||
assert "Legal Hold #1,Legal Hold #2" not in result.output | ||
assert "123456789,987654321" not in result.output | ||
assert "legalHoldUid" not in result.output | ||
assert "[email protected]" in result.output | ||
|
||
|
||
def test_list_legal_hold_flag_reports_none_if_no_matters_exist( | ||
runner, cli_state, get_all_users_success, get_custodian_failure, get_matter_failure | ||
): | ||
result = runner.invoke( | ||
cli, ["users", "list", "--include-legal-hold-membership"], obj=cli_state | ||
) | ||
|
||
assert "Legal Hold #1,Legal Hold #2" not in result.output | ||
assert "123456789,987654321" not in result.output | ||
assert "legalHoldUid" not in result.output | ||
assert "[email protected]" in result.output | ||
|
||
|
||
def test_list_legal_hold_values_not_included_for_legal_hold_user_if_legal_hold_flag_not_passed( | ||
runner, | ||
cli_state, | ||
get_all_users_success, | ||
get_all_custodian_success, | ||
get_all_matter_success, | ||
): | ||
result = runner.invoke(cli, ["users", "list"], obj=cli_state) | ||
assert "Legal Hold #1,Legal Hold #2" not in result.output | ||
assert "123456789,987654321" not in result.output | ||
assert "[email protected]" in result.output | ||
|
||
|
||
def test_list_include_legal_hold_membership_merges_in_and_concats_legal_hold_info( | ||
runner, | ||
cli_state, | ||
get_all_users_success, | ||
get_all_custodian_success, | ||
get_all_matter_success, | ||
): | ||
result = runner.invoke( | ||
cli, ["users", "list", "--include-legal-hold-membership"], obj=cli_state | ||
) | ||
|
||
assert "Legal Hold #1,Legal Hold #2" in result.output | ||
assert "123456789,987654321" in result.output | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get tests for the following two cases: 1.) A user is not on any legal hold but the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added these tests. The code didn't handle cases where 0 custodians were returned. Thanks for suggesting this test case. I also added a test for cases where the flag |
||
def test_add_user_role_adds( | ||
runner, cli_state, get_user_id_success, get_available_roles_success | ||
): | ||
|
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.
It would be nice to be able to pass in user friendly keys for Table format headers for when using
DataFrameOutputFormatter
, as that was the norm before.Table format should use label-esque keys while all the other ones should use raw API values.
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.
The strange format of
"legalHold.legalHoldUid"
does not (should not) come through the final output. This syntax gets introduced with thejson_normalize
command, which flattens the json structure into nested columns names.