Skip to content

Commit 53c5ffe

Browse files
Fix list subcommand headers and make cases show display all fields in table format (#211)
1 parent 57262dc commit 53c5ffe

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

src/code42cli/cmds/cases.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
name_option = click.option("--name", help="Name of the case.",)
2121
assignee_option = click.option("--assignee", help="User UID of the assignee.")
2222
description_option = click.option("--description", help="Description of the case.")
23-
notes_option = click.option("--notes", help="Notes on the case.")
23+
findings_option = click.option("--findings", help="Findings on the case.")
2424
subject_option = click.option("--subject", help="User UID of a subject of the case.")
2525
status_option = click.option(
2626
"--status",
@@ -42,15 +42,16 @@ def _get_cases_header():
4242
"name": "Name",
4343
"assignee": "Assignee",
4444
"status": "Status",
45+
"subject": "Subject",
4546
"createdAt": "Creation Time",
46-
"findings": "Notes",
47+
"updatedAt": "Last Update Time",
4748
}
4849

4950

5051
def _get_events_header():
5152
return {
5253
"eventId": "Event Id",
53-
"eventTimestatmp": "Timestamp",
54+
"eventTimestamp": "Timestamp",
5455
"filePath": "Path",
5556
"fileName": "File",
5657
"exposure": "Exposure",
@@ -68,17 +69,17 @@ def cases(state):
6869
@click.argument("name")
6970
@assignee_option
7071
@description_option
71-
@notes_option
72+
@findings_option
7273
@subject_option
7374
@sdk_options()
74-
def create(state, name, subject, assignee, description, notes):
75+
def create(state, name, subject, assignee, description, findings):
7576
"""Create a new case."""
7677
state.sdk.cases.create(
7778
name,
7879
subject=subject,
7980
assignee=assignee,
8081
description=description,
81-
findings=notes,
82+
findings=findings,
8283
)
8384

8485

@@ -87,19 +88,19 @@ def create(state, name, subject, assignee, description, notes):
8788
@name_option
8889
@assignee_option
8990
@description_option
90-
@notes_option
91+
@findings_option
9192
@subject_option
9293
@status_option
9394
@sdk_options()
94-
def update(state, case_number, name, subject, assignee, description, notes, status):
95+
def update(state, case_number, name, subject, assignee, description, findings, status):
9596
"""Update case details for the given case."""
9697
state.sdk.cases.update(
9798
case_number,
9899
name=name,
99100
subject=subject,
100101
assignee=assignee,
101102
description=description,
102-
findings=notes,
103+
findings=findings,
103104
status=status,
104105
)
105106

@@ -172,7 +173,7 @@ def _display_file_events(events):
172173
@format_option
173174
def show(state, case_number, format, include_file_events):
174175
"""Show case details."""
175-
formatter = OutputFormatter(format, _get_cases_header())
176+
formatter = OutputFormatter(format)
176177
try:
177178
response = state.sdk.cases.get(case_number)
178179
formatter.echo_formatted_list([response.data])

tests/cmds/test_cases.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@
1010
from code42cli.main import cli
1111

1212

13-
EVENT_DETAILS = """{"eventId": "0_1d71796f-af5b-4231-9d8e-df6434da4663_984418168383179707_986472527798692818_971"}
14-
"""
15-
16-
ALL_EVENTS = """{"events": [{"eventId": "0_1d71796f-af5b-4231-9d8e-df6434da4663_984418168383179707_986472527798692818_971"}]}"""
17-
18-
ALL_CASES = """{"cases": [{"number": 3,"name": "test@test.test"}], "totalCount": 31}"""
19-
20-
CASE_DETAILS = """{"number": 3, "name": "test@test.test"}"""
21-
13+
ALL_EVENTS = """{
14+
"events": [
15+
{
16+
"eventId": "0_1d71796f-af5b-4231-9d8e-df6434da4663_984418168383179707_986472527798692818_971",
17+
"eventTimestamp": "2020-12-23T12:41:38.592Z"
18+
}
19+
]
20+
}"""
21+
ALL_CASES = """{
22+
"cases": [
23+
{
24+
"number": 3,
25+
"name": "test@test.test",
26+
"updatedAt": "2021-01-24T11:00:04.217878Z",
27+
"subject": "942897"
28+
}
29+
],
30+
"totalCount": 31
31+
}"""
32+
CASE_DETAILS = '{"number": 3, "name": "test@test.test"}'
2233
CASES_COMMAND = "cases"
2334
CASES_FILE_EVENTS_COMMAND = "cases file-events"
24-
2535
MISSING_ARGUMENT_ERROR = "Missing argument '{}'."
2636
MISSING_NAME = MISSING_ARGUMENT_ERROR.format("NAME")
2737
MISSING_CASE_NUMBER = MISSING_ARGUMENT_ERROR.format("CASE_NUMBER")
@@ -63,7 +73,7 @@ def test_create_with_optional_fields_calls_create_with_expected_params(
6373
"a",
6474
"--description",
6575
"d",
66-
"--notes",
76+
"--findings",
6777
"n",
6878
"--subject",
6979
"s",
@@ -90,7 +100,7 @@ def test_update_with_optional_fields_calls_update_with_expected_params(
90100
"a",
91101
"--description",
92102
"d",
93-
"--notes",
103+
"--findings",
94104
"n",
95105
"--subject",
96106
"s",
@@ -227,6 +237,8 @@ def gen():
227237
cli_state.sdk.cases.get_all.return_value = gen()
228238
result = runner.invoke(cli, ["cases", "list"], obj=cli_state,)
229239
assert "test@test.test" in result.output
240+
assert "2021-01-24T11:00:04.217878Z" in result.output
241+
assert "942897" in result.output
230242

231243

232244
def test_show_returns_expected_data_with_include_file_events_option(
@@ -250,6 +262,7 @@ def test_events_list_returns_expected_data(runner, cli_state):
250262
"0_1d71796f-af5b-4231-9d8e-df6434da4663_984418168383179707_986472527798692818_971"
251263
in result.output
252264
)
265+
assert "2020-12-23T12:41:38.592Z" in result.output
253266

254267

255268
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)