|
6 | 6 |
|
7 | 7 | from code42cli.main import cli |
8 | 8 |
|
| 9 | + |
9 | 10 | TEST_ROLE_RETURN_DATA = { |
10 | 11 | "data": [{"roleName": "Customer Cloud Admin", "roleId": "1234543"}] |
11 | 12 | } |
12 | | - |
13 | 13 | TEST_USERS_RESPONSE = { |
14 | 14 | "users": [ |
15 | 15 | { |
16 | | - "userId": 1234, |
17 | | - "userUid": "997962681513153325", |
| 16 | + "firstName": "test", |
| 17 | + "lastName": "username", |
| 18 | + "orgId": 4321, |
| 19 | + "orgUid": "44444444", |
| 20 | + "orgName": "ORG_NAME", |
18 | 21 | "status": "Active", |
19 | | - "username": "test_username@code42.com", |
| 22 | + "notes": "This is a note.", |
| 23 | + "active": True, |
| 24 | + "blocked": False, |
20 | 25 | "creationDate": "2021-03-12T20:07:40.898Z", |
21 | 26 | "modificationDate": "2021-03-12T20:07:40.938Z", |
| 27 | + "userId": 1234, |
| 28 | + "username": "test.username@example.com", |
| 29 | + "userUid": "911162111513111325", |
| 30 | + "invited": False, |
| 31 | + "quotaInBytes": 55555, |
22 | 32 | } |
23 | 33 | ] |
24 | 34 | } |
@@ -51,14 +61,49 @@ def get_available_roles_success(cli_state, get_available_roles_response): |
51 | 61 | cli_state.sdk.users.get_available_roles.return_value = get_available_roles_response |
52 | 62 |
|
53 | 63 |
|
54 | | -def test_list_outputs_appropriate_columns(runner, cli_state, get_all_users_success): |
55 | | - result = runner.invoke(cli, ["users", "list"], obj=cli_state) |
| 64 | +def test_list_when_non_table_format_outputs_expected_columns( |
| 65 | + runner, cli_state, get_all_users_success |
| 66 | +): |
| 67 | + result = runner.invoke(cli, ["users", "list", "-f", "CSV"], obj=cli_state) |
| 68 | + assert "firstName" in result.output |
| 69 | + assert "lastName" in result.output |
| 70 | + assert "orgId" in result.output |
| 71 | + assert "orgUid" in result.output |
| 72 | + assert "orgName" in result.output |
| 73 | + assert "status" in result.output |
| 74 | + assert "notes" in result.output |
| 75 | + assert "active" in result.output |
| 76 | + assert "blocked" in result.output |
| 77 | + assert "creationDate" in result.output |
| 78 | + assert "modificationDate" in result.output |
56 | 79 | assert "userId" in result.output |
| 80 | + assert "username" in result.output |
57 | 81 | assert "userUid" in result.output |
| 82 | + assert "invited" in result.output |
| 83 | + assert "quotaInBytes" in result.output |
| 84 | + |
| 85 | + |
| 86 | +def test_list_when_table_format_outputs_expected_columns( |
| 87 | + runner, cli_state, get_all_users_success |
| 88 | +): |
| 89 | + result = runner.invoke(cli, ["users", "list", "-f", "TABLE"], obj=cli_state) |
| 90 | + assert "orgUid" in result.output |
58 | 91 | assert "status" in result.output |
59 | 92 | assert "username" in result.output |
60 | | - assert "creationDate" in result.output |
61 | | - assert "modificationDate" in result.output |
| 93 | + assert "userUid" in result.output |
| 94 | + |
| 95 | + assert "firstName" not in result.output |
| 96 | + assert "lastName" not in result.output |
| 97 | + assert "orgId" not in result.output |
| 98 | + assert "orgName" not in result.output |
| 99 | + assert "notes" not in result.output |
| 100 | + assert "active" not in result.output |
| 101 | + assert "blocked" not in result.output |
| 102 | + assert "creationDate" not in result.output |
| 103 | + assert "modificationDate" not in result.output |
| 104 | + assert "userId" not in result.output |
| 105 | + assert "invited" not in result.output |
| 106 | + assert "quotaInBytes" not in result.output |
62 | 107 |
|
63 | 108 |
|
64 | 109 | def test_list_users_calls_users_get_all_with_expected_role_id( |
|
0 commit comments