Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/code42cli/cmds/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def bulk(state):

FILE_EVENTS_HEADERS = [
"number",
"eventId",
"event_id",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bugfix here

]

case_file_events_generate_template = generate_template_cmd_factory(
Expand All @@ -288,15 +288,15 @@ def bulk(state):
@bulk.command(
name="add",
help="Bulk associate file events to cases using a CSV file with "
"format: {}.".format(",".join(FILE_EVENTS_HEADERS)),
f"format: {','.join(FILE_EVENTS_HEADERS)}.",
)
@read_csv_arg(headers=FILE_EVENTS_HEADERS)
@sdk_options()
def bulk_add(state, csv_rows):
sdk = state.sdk

def handle_row(case_number, event_id):
sdk.cases.file_events.add(case_number, event_id)
def handle_row(number, event_id):
sdk.cases.file_events.add(number, event_id)

run_bulk_process(
handle_row, csv_rows, progress_label="Associating file events to cases:",
Expand All @@ -306,15 +306,15 @@ def handle_row(case_number, event_id):
@bulk.command(
name="remove",
help="Bulk remove the file event association from cases using a CSV file with "
"format: {}.".format(",".join(FILE_EVENTS_HEADERS)),
f"format: {','.join(FILE_EVENTS_HEADERS)}.",
)
@read_csv_arg(headers=FILE_EVENTS_HEADERS)
@sdk_options()
def bulk_remove(state, csv_rows):
sdk = state.sdk

def handle_row(case_number, event_id):
sdk.cases.file_events.delete(case_number, event_id)
def handle_row(number, event_id):
sdk.cases.file_events.delete(number, event_id)

run_bulk_process(
handle_row,
Expand Down
12 changes: 6 additions & 6 deletions tests/cmds/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@ def test_add_bulk_file_events_to_cases_uses_expected_arguments(
bulk_processor = mocker.patch("code42cli.cmds.cases.run_bulk_process")
with runner.isolated_filesystem():
with open("test_add.csv", "w") as csv:
csv.writelines(["number,eventId\n", "1,abc\n", "2,pqr\n"])
csv.writelines(["number,event_id\n", "1,abc\n", "2,pqr\n"])
runner.invoke(
cli,
["cases", "file-events", "bulk", "add", "test_add.csv"],
obj=cli_state_with_user,
)
assert bulk_processor.call_args[0][1] == [
{"number": "1", "eventId": "abc"},
{"number": "2", "eventId": "pqr"},
{"number": "1", "event_id": "abc"},
{"number": "2", "event_id": "pqr"},
]


Expand All @@ -490,13 +490,13 @@ def test_remove_bulk_file_events_from_cases_uses_expected_arguments(
bulk_processor = mocker.patch("code42cli.cmds.cases.run_bulk_process")
with runner.isolated_filesystem():
with open("test_remove.csv", "w") as csv:
csv.writelines(["number,eventId\n", "1,abc\n", "2,pqr\n"])
csv.writelines(["number,event_id\n", "1,abc\n", "2,pqr\n"])
runner.invoke(
cli,
["cases", "file-events", "bulk", "remove", "test_remove.csv"],
obj=cli_state_with_user,
)
assert bulk_processor.call_args[0][1] == [
{"number": "1", "eventId": "abc"},
{"number": "2", "eventId": "pqr"},
{"number": "1", "event_id": "abc"},
{"number": "2", "event_id": "pqr"},
]