Skip to content

Commit 3678edd

Browse files
committed
refactor(convert): use named kwargs
1 parent 756ca13 commit 3678edd

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

compiler_admin/commands/time/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ def _get_source_converter(source):
2121
def convert(args: Namespace, *extras):
2222
converter = _get_source_converter(args.input)
2323

24-
converter(args.input, args.output, args.client)
24+
converter(source_path=args.input, output_path=args.output, client_name=args.client)
2525

2626
return RESULT_SUCCESS

compiler_admin/services/harvest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ def _toggl_client_name():
3333
def convert_to_toggl(
3434
source_path: str | TextIO = sys.stdin,
3535
output_path: str | TextIO = sys.stdout,
36-
client_name: str = None,
3736
output_cols: list[str] = TOGGL_COLUMNS,
37+
client_name: str = None,
38+
**kwargs,
3839
):
3940
"""Convert Harvest formatted entries in source_path to equivalent Toggl formatted entries.
4041

compiler_admin/services/toggl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,20 @@ def _str_timedelta(td: str):
5757
def convert_to_harvest(
5858
source_path: str | TextIO = sys.stdin,
5959
output_path: str | TextIO = sys.stdout,
60-
client_name: str = None,
6160
output_cols: list[str] = HARVEST_COLUMNS,
61+
client_name: str = None,
62+
**kwargs,
6263
):
6364
"""Convert Toggl formatted entries in source_path to equivalent Harvest formatted entries.
6465
6566
Args:
6667
source_path: The path to a readable CSV file of Toggl time entries; or a readable buffer of the same.
6768
68-
client_name (str): The value to assign in the output "Client" field
69+
output_path: The path to a CSV file where Harvest time entries will be written; or a writeable buffer for the same.
6970
7071
output_cols (list[str]): A list of column names for the output
7172
72-
output_path: The path to a CSV file where Harvest time entries will be written; or a writeable buffer for the same.
73+
client_name (str): The value to assign in the output "Client" field
7374
7475
Returns:
7576
None. Either prints the resulting CSV data or writes to output_path.

tests/commands/time/test_convert.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ def test_convert(mock_get_source_converter):
4242

4343
assert res == RESULT_SUCCESS
4444
mock_get_source_converter.assert_called_once_with(args.input)
45-
mock_get_source_converter.return_value.assert_called_once_with(args.input, args.output, args.client)
45+
mock_get_source_converter.return_value.assert_called_once_with(
46+
source_path=args.input, output_path=args.output, client_name=args.client
47+
)

tests/services/test_harvest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_convert_to_toggl_sample(harvest_file, toggl_file):
9595
output = None
9696

9797
with StringIO() as output_data:
98-
convert_to_toggl(harvest_file, output_data, "Test Client 123")
98+
convert_to_toggl(harvest_file, output_data, client_name="Test Client 123")
9999
output = output_data.getvalue()
100100

101101
assert output

tests/services/test_toggl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_convert_to_harvest_sample(toggl_file, harvest_file, mock_google_user_in
160160
output = None
161161

162162
with StringIO() as output_data:
163-
convert_to_harvest(toggl_file, output_data, "Test Client 123")
163+
convert_to_harvest(toggl_file, output_data, client_name="Test Client 123")
164164
output = output_data.getvalue()
165165

166166
assert output

0 commit comments

Comments
 (0)