|
279 | 279 | }, |
280 | 280 | ] |
281 | 281 | } |
| 282 | +API_CLIENT_MATTER_RESPONSE = [ |
| 283 | + { |
| 284 | + "legalHoldUid": "123456789", |
| 285 | + "name": "Test legal hold matter", |
| 286 | + "description": "", |
| 287 | + "notes": None, |
| 288 | + "holdExtRef": None, |
| 289 | + "active": True, |
| 290 | + "creationDate": "2020-08-05T10:49:58.353-05:00", |
| 291 | + "lastModified": "2020-08-05T10:49:58.358-05:00", |
| 292 | + "creator": { |
| 293 | + "userUid": "12345", |
| 294 | + "username": "user@code42.com", |
| 295 | + "email": "user@code42.com", |
| 296 | + "userExtRef": None, |
| 297 | + }, |
| 298 | + "holdPolicyUid": "966191295667423997", |
| 299 | + }, |
| 300 | + { |
| 301 | + "legalHoldUid": "987654321", |
| 302 | + "name": "Another Matter", |
| 303 | + "description": "", |
| 304 | + "notes": None, |
| 305 | + "holdExtRef": None, |
| 306 | + "active": True, |
| 307 | + "creationDate": "2020-05-20T15:58:31.375-05:00", |
| 308 | + "lastModified": "2020-05-28T13:49:16.098-05:00", |
| 309 | + "creator": { |
| 310 | + "userUid": "76543", |
| 311 | + "username": "user2@code42.com", |
| 312 | + "email": "user2@code42.com", |
| 313 | + "userExtRef": None, |
| 314 | + }, |
| 315 | + "holdPolicyUid": "946178665645035826", |
| 316 | + }, |
| 317 | +] |
282 | 318 | ALL_CUSTODIANS_RESPONSE = { |
283 | 319 | "legalHoldMemberships": [ |
284 | 320 | { |
|
310 | 346 | }, |
311 | 347 | ] |
312 | 348 | } |
| 349 | +API_CLIENT_ALL_CUSTODIANS_RESPONSE = [ |
| 350 | + { |
| 351 | + "legalHoldMembershipUid": "99999", |
| 352 | + "active": True, |
| 353 | + "creationDate": "2020-07-16T08:50:23.405Z", |
| 354 | + "legalHold": { |
| 355 | + "legalHoldUid": "123456789", |
| 356 | + "name": "Test legal hold matter", |
| 357 | + }, |
| 358 | + "user": { |
| 359 | + "userUid": "840103986007089121", |
| 360 | + "username": "ttranda_deactivated@ttrantest.com", |
| 361 | + "email": "ttranda_deactivated@ttrantest.com", |
| 362 | + "userExtRef": None, |
| 363 | + }, |
| 364 | + }, |
| 365 | + { |
| 366 | + "legalHoldMembershipUid": "88888", |
| 367 | + "active": True, |
| 368 | + "creationDate": "2020-07-16T08:50:23.405Z", |
| 369 | + "legalHold": {"legalHoldUid": "987654321", "name": "Another Matter"}, |
| 370 | + "user": { |
| 371 | + "userUid": "840103986007089121", |
| 372 | + "username": "ttranda_deactivated@ttrantest.com", |
| 373 | + "email": "ttranda_deactivated@ttrantest.com", |
| 374 | + "userExtRef": None, |
| 375 | + }, |
| 376 | + }, |
| 377 | +] |
313 | 378 |
|
314 | 379 |
|
315 | 380 | @pytest.fixture |
@@ -355,12 +420,18 @@ def users_list_generator(): |
355 | 420 | yield TEST_USERS_LIST_PAGE |
356 | 421 |
|
357 | 422 |
|
358 | | -def matter_list_generator(): |
359 | | - yield MATTER_RESPONSE |
| 423 | +def matter_list_generator(mocker, api_client=False): |
| 424 | + if api_client: |
| 425 | + yield create_mock_response(mocker, data=API_CLIENT_MATTER_RESPONSE) |
| 426 | + else: |
| 427 | + yield create_mock_response(mocker, data=MATTER_RESPONSE) |
360 | 428 |
|
361 | 429 |
|
362 | | -def custodian_list_generator(): |
363 | | - yield ALL_CUSTODIANS_RESPONSE |
| 430 | +def custodian_list_generator(mocker, api_client=False): |
| 431 | + if api_client: |
| 432 | + yield create_mock_response(mocker, data=API_CLIENT_ALL_CUSTODIANS_RESPONSE) |
| 433 | + else: |
| 434 | + yield create_mock_response(mocker, data=ALL_CUSTODIANS_RESPONSE) |
364 | 435 |
|
365 | 436 |
|
366 | 437 | @pytest.fixture |
@@ -446,14 +517,28 @@ def get_all_users_success(cli_state): |
446 | 517 |
|
447 | 518 |
|
448 | 519 | @pytest.fixture |
449 | | -def get_all_matter_success(cli_state): |
450 | | - cli_state.sdk.legalhold.get_all_matters.return_value = matter_list_generator() |
| 520 | +def get_all_matter_success(mocker, cli_state): |
| 521 | + cli_state.sdk.legalhold.get_all_matters.return_value = matter_list_generator(mocker) |
| 522 | + |
| 523 | + |
| 524 | +@pytest.fixture |
| 525 | +def get_api_client_all_matter_success(mocker, cli_state): |
| 526 | + cli_state.sdk.legalhold.get_all_matters.return_value = matter_list_generator( |
| 527 | + mocker, api_client=True |
| 528 | + ) |
451 | 529 |
|
452 | 530 |
|
453 | 531 | @pytest.fixture |
454 | | -def get_all_custodian_success(cli_state): |
| 532 | +def get_all_custodian_success(mocker, cli_state): |
455 | 533 | cli_state.sdk.legalhold.get_all_matter_custodians.return_value = ( |
456 | | - custodian_list_generator() |
| 534 | + custodian_list_generator(mocker) |
| 535 | + ) |
| 536 | + |
| 537 | + |
| 538 | +@pytest.fixture |
| 539 | +def get_api_client_all_custodian_success(mocker, cli_state): |
| 540 | + cli_state.sdk.legalhold.get_all_matter_custodians.return_value = ( |
| 541 | + custodian_list_generator(mocker, api_client=True) |
457 | 542 | ) |
458 | 543 |
|
459 | 544 |
|
@@ -740,6 +825,21 @@ def test_add_legal_hold_membership_to_device_dataframe_adds_legal_hold_columns_t |
740 | 825 | assert "legalHoldName" in result.columns |
741 | 826 |
|
742 | 827 |
|
| 828 | +def test_api_client_add_legal_hold_membership_to_device_dataframe_adds_legal_hold_columns_to_dataframe( |
| 829 | + cli_state, get_api_client_all_matter_success, get_api_client_all_custodian_success |
| 830 | +): |
| 831 | + cli_state.sdk._auth_flag = 1 |
| 832 | + testdf = DataFrame.from_records( |
| 833 | + [ |
| 834 | + {"userUid": "840103986007089121", "status": "Active"}, |
| 835 | + {"userUid": "836473273124890369", "status": "Active, Deauthorized"}, |
| 836 | + ] |
| 837 | + ) |
| 838 | + result = _add_legal_hold_membership_to_device_dataframe(cli_state.sdk, testdf) |
| 839 | + assert "legalHoldUid" in result.columns |
| 840 | + assert "legalHoldName" in result.columns |
| 841 | + |
| 842 | + |
743 | 843 | def test_list_without_page_size_option_defaults_to_100_results_per_page( |
744 | 844 | cli_state, runner |
745 | 845 | ): |
|
0 commit comments