|
26 | 26 | "active": True, |
27 | 27 | "agentType": "COMBINED", |
28 | 28 | "agentHealthIssueTypes": ["NOT_CONNECTING"], |
| 29 | + "agentHealthModificationDate": "2022-07-14T17:03:22.123000Z", |
29 | 30 | "appVersion": "1.0", |
30 | 31 | "productVersion": "2.0", |
31 | 32 | "lastConnected": "2022-07-14T17:05:44.524000Z", |
|
46 | 47 | "active": True, |
47 | 48 | "agentType": "COMBINED", |
48 | 49 | "agentHealthIssueTypes": [], |
| 50 | + "agentHealthModificationDate": "2022-07-14T17:02:15.456000Z", |
49 | 51 | "appVersion": "1.0", |
50 | 52 | "productVersion": "2.0", |
51 | 53 | "lastConnected": "2022-07-14T17:05:44.524000Z", |
|
65 | 67 | "active": True, |
66 | 68 | "agentType": "COMBINED", |
67 | 69 | "agentHealthIssueTypes": [], |
| 70 | + "agentHealthModificationDate": "2022-07-14T17:01:30.789000Z", |
68 | 71 | "appVersion": "1.0", |
69 | 72 | "productVersion": "2.0", |
70 | 73 | "lastConnected": "2022-07-14T17:05:44.524000Z", |
@@ -117,6 +120,9 @@ def test_get_agent_returns_expected_data(mock_get_agent): |
117 | 120 | assert agent.modification_date == datetime.fromisoformat( |
118 | 121 | TEST_AGENT_1["modificationDate"].replace("Z", "+00:00") |
119 | 122 | ) |
| 123 | + assert agent.agent_health_modification_date == datetime.fromisoformat( |
| 124 | + TEST_AGENT_1["agentHealthModificationDate"].replace("Z", "+00:00") |
| 125 | + ) |
120 | 126 |
|
121 | 127 |
|
122 | 128 | def test_get_page_when_default_query_params_returns_expected_data( |
@@ -165,6 +171,35 @@ def test_get_page_when_custom_query_params_returns_expected_data( |
165 | 171 | assert page.total_count == len(page.agents) == 2 |
166 | 172 |
|
167 | 173 |
|
| 174 | +def test_get_page_when_agent_health_modified_in_last_days_passed_makes_expected_call( |
| 175 | + httpserver_auth: HTTPServer, |
| 176 | +): |
| 177 | + query = { |
| 178 | + "agentHealthModifiedInLastDays": 7, |
| 179 | + "srtKey": "NAME", |
| 180 | + "srtDir": "ASC", |
| 181 | + "pageSize": 500, |
| 182 | + "page": 1, |
| 183 | + } |
| 184 | + |
| 185 | + agents_data = { |
| 186 | + "agents": [TEST_AGENT_1, TEST_AGENT_2], |
| 187 | + "totalCount": 2, |
| 188 | + "pageSize": 500, |
| 189 | + "page": 1, |
| 190 | + } |
| 191 | + httpserver_auth.expect_request( |
| 192 | + uri="/v1/agents", method="GET", query_string=urlencode(query) |
| 193 | + ).respond_with_json(agents_data) |
| 194 | + |
| 195 | + client = Client() |
| 196 | + page = client.agents.v1.get_page(agent_health_modified_in_last_days=7) |
| 197 | + assert isinstance(page, AgentsPage) |
| 198 | + assert page.agents[0].json() == json.dumps(TEST_AGENT_1, separators=(",", ":")) |
| 199 | + assert page.agents[1].json() == json.dumps(TEST_AGENT_2, separators=(",", ":")) |
| 200 | + assert page.total_count == len(page.agents) == 2 |
| 201 | + |
| 202 | + |
168 | 203 | def test_iter_all_when_default_params_returns_expected_data( |
169 | 204 | httpserver_auth: HTTPServer, |
170 | 205 | ): |
@@ -346,6 +381,32 @@ def test_cli_list_when_unhealthy_option_passed_with_string_parses_issue_types_co |
346 | 381 | assert result.exit_code == 0 |
347 | 382 |
|
348 | 383 |
|
| 384 | +def test_cli_list_when_health_modified_days_option_passed_makes_expected_call( |
| 385 | + httpserver_auth: HTTPServer, runner |
| 386 | +): |
| 387 | + query = { |
| 388 | + "agentHealthModifiedInLastDays": 7, |
| 389 | + "srtKey": "NAME", |
| 390 | + "srtDir": "ASC", |
| 391 | + "pageSize": 500, |
| 392 | + "page": 1, |
| 393 | + } |
| 394 | + |
| 395 | + agents_data = { |
| 396 | + "agents": [TEST_AGENT_1, TEST_AGENT_2], |
| 397 | + "totalCount": 2, |
| 398 | + "pageSize": 500, |
| 399 | + "page": 1, |
| 400 | + } |
| 401 | + httpserver_auth.expect_request( |
| 402 | + uri="/v1/agents", method="GET", query_string=urlencode(query) |
| 403 | + ).respond_with_json(agents_data) |
| 404 | + |
| 405 | + result = runner.invoke(incydr, ["agents", "list", "--agent-health-modified-within-days", "7"]) |
| 406 | + httpserver_auth.check() |
| 407 | + assert result.exit_code == 0 |
| 408 | + |
| 409 | + |
349 | 410 | def test_cli_show_when_custom_params_makes_expected_call( |
350 | 411 | httpserver_auth: HTTPServer, runner, mock_get_agent |
351 | 412 | ): |
|
0 commit comments