|
10 | 10 | from py42.exceptions import Py42BadRequestError |
11 | 11 | from py42.exceptions import Py42ForbiddenError |
12 | 12 | from py42.exceptions import Py42NotFoundError |
| 13 | +from py42.exceptions import Py42OrgNotFoundError |
13 | 14 | from tests.conftest import create_mock_response |
14 | 15 |
|
15 | 16 | from code42cli.cmds.devices import _add_backup_set_settings_to_dataframe |
@@ -725,6 +726,40 @@ def test_list_include_legal_hold_membership_merges_in_and_concats_legal_hold_inf |
725 | 726 | assert "123456789,987654321" in result.output |
726 | 727 |
|
727 | 728 |
|
| 729 | +def test_list_invalid_org_uid_raises_error(runner, cli_state, custom_error): |
| 730 | + custom_error.response.text = "Unable to find org" |
| 731 | + invalid_org_uid = "invalid_org_uid" |
| 732 | + cli_state.sdk.devices.get_all.side_effect = Py42OrgNotFoundError( |
| 733 | + custom_error, invalid_org_uid |
| 734 | + ) |
| 735 | + result = runner.invoke( |
| 736 | + cli, ["devices", "list", "--org-uid", invalid_org_uid], obj=cli_state |
| 737 | + ) |
| 738 | + assert result.exit_code == 1 |
| 739 | + assert ( |
| 740 | + f"Error: The organization with UID '{invalid_org_uid}' was not found." |
| 741 | + in result.output |
| 742 | + ) |
| 743 | + |
| 744 | + |
| 745 | +def test_list_backup_sets_invalid_org_uid_raises_error(runner, cli_state, custom_error): |
| 746 | + custom_error.response.text = "Unable to find org" |
| 747 | + invalid_org_uid = "invalid_org_uid" |
| 748 | + cli_state.sdk.devices.get_all.side_effect = Py42OrgNotFoundError( |
| 749 | + custom_error, invalid_org_uid |
| 750 | + ) |
| 751 | + result = runner.invoke( |
| 752 | + cli, |
| 753 | + ["devices", "list-backup-sets", "--org-uid", invalid_org_uid], |
| 754 | + obj=cli_state, |
| 755 | + ) |
| 756 | + assert result.exit_code == 1 |
| 757 | + assert ( |
| 758 | + f"Error: The organization with UID '{invalid_org_uid}' was not found." |
| 759 | + in result.output |
| 760 | + ) |
| 761 | + |
| 762 | + |
728 | 763 | def test_break_backup_usage_into_total_storage_correctly_calculates_values(): |
729 | 764 | test_backupusage_cell = json.loads(TEST_BACKUPUSAGE_RESPONSE)["data"]["backupUsage"] |
730 | 765 | result = _break_backup_usage_into_total_storage(test_backupusage_cell) |
|
0 commit comments