@@ -104,7 +104,7 @@ def test_main_init_gyb(mock_commands_init):
104104def test_main_init_no_username (mock_commands_init ):
105105 with pytest .raises (SystemExit ):
106106 main (argv = ["init" ])
107- assert mock_commands_init .call_count == 0
107+ assert mock_commands_init .call_count == 0
108108
109109
110110def test_main_time_convert_default (mock_commands_time ):
@@ -114,7 +114,14 @@ def test_main_time_convert_default(mock_commands_time):
114114 call_args = mock_commands_time .call_args .args
115115 assert (
116116 Namespace (
117- func = mock_commands_time , command = "time" , subcommand = "convert" , client = None , input = sys .stdin , output = sys .stdout
117+ func = mock_commands_time ,
118+ command = "time" ,
119+ subcommand = "convert" ,
120+ client = None ,
121+ input = sys .stdin ,
122+ output = sys .stdout ,
123+ from_fmt = "toggl" ,
124+ to_fmt = "harvest" ,
118125 )
119126 in call_args
120127 )
@@ -129,7 +136,16 @@ def test_main_time_convert_env(monkeypatch, mock_commands_time):
129136 mock_commands_time .assert_called_once ()
130137 call_args = mock_commands_time .call_args .args
131138 assert (
132- Namespace (func = mock_commands_time , command = "time" , subcommand = "convert" , client = None , input = "toggl" , output = "harvest" )
139+ Namespace (
140+ func = mock_commands_time ,
141+ command = "time" ,
142+ subcommand = "convert" ,
143+ client = None ,
144+ input = "toggl" ,
145+ output = "harvest" ,
146+ from_fmt = "toggl" ,
147+ to_fmt = "harvest" ,
148+ )
133149 in call_args
134150 )
135151
@@ -231,6 +247,8 @@ def test_main_time_convert_client(mock_commands_time):
231247 client = "client123" ,
232248 input = sys .stdin ,
233249 output = sys .stdout ,
250+ from_fmt = "toggl" ,
251+ to_fmt = "harvest" ,
234252 )
235253 in call_args
236254 )
@@ -249,6 +267,8 @@ def test_main_time_convert_input(mock_commands_time):
249267 client = None ,
250268 input = "file.csv" ,
251269 output = sys .stdout ,
270+ from_fmt = "toggl" ,
271+ to_fmt = "harvest" ,
252272 )
253273 in call_args
254274 )
@@ -267,10 +287,62 @@ def test_main_time_convert_output(mock_commands_time):
267287 client = None ,
268288 input = sys .stdin ,
269289 output = "file.csv" ,
290+ from_fmt = "toggl" ,
291+ to_fmt = "harvest" ,
292+ )
293+ in call_args
294+ )
295+
296+
297+ def test_main_time_convert_from (mock_commands_time ):
298+ main (argv = ["time" , "convert" , "--from" , "harvest" ])
299+
300+ mock_commands_time .assert_called_once ()
301+ call_args = mock_commands_time .call_args .args
302+ assert (
303+ Namespace (
304+ func = mock_commands_time ,
305+ command = "time" ,
306+ subcommand = "convert" ,
307+ client = None ,
308+ input = sys .stdin ,
309+ output = sys .stdout ,
310+ from_fmt = "harvest" ,
311+ to_fmt = "harvest" ,
270312 )
271313 in call_args
272314 )
273315
316+ with pytest .raises (SystemExit ):
317+ main (argv = ["time" , "convert" , "--from" , "nope" ])
318+ # it should not have been called an additional time from the first
319+ mock_commands_time .assert_called_once ()
320+
321+
322+ def test_main_time_convert_to (mock_commands_time ):
323+ main (argv = ["time" , "convert" , "--to" , "toggl" ])
324+
325+ mock_commands_time .assert_called_once ()
326+ call_args = mock_commands_time .call_args .args
327+ assert (
328+ Namespace (
329+ func = mock_commands_time ,
330+ command = "time" ,
331+ subcommand = "convert" ,
332+ client = None ,
333+ input = sys .stdin ,
334+ output = sys .stdout ,
335+ from_fmt = "toggl" ,
336+ to_fmt = "toggl" ,
337+ )
338+ in call_args
339+ )
340+
341+ with pytest .raises (SystemExit ):
342+ main (argv = ["time" , "convert" , "--to" , "nope" ])
343+ # it should not have been called an additional time from the first
344+ mock_commands_time .assert_called_once ()
345+
274346
275347def test_main_user_alumni (mock_commands_user ):
276348 main (argv = ["user" , "alumni" , "username" ])
@@ -355,7 +427,7 @@ def test_main_user_create_extras(mock_commands_user):
355427def test_main_user_create_no_username (mock_commands_user ):
356428 with pytest .raises (SystemExit ):
357429 main (argv = ["user" , "create" ])
358- assert mock_commands_user .call_count == 0
430+ assert mock_commands_user .call_count == 0
359431
360432
361433def test_main_user_convert (mock_commands_user ):
@@ -380,13 +452,13 @@ def test_main_user_convert(mock_commands_user):
380452def test_main_user_convert_no_username (mock_commands_user ):
381453 with pytest .raises (SystemExit ):
382454 main (argv = ["user" , "convert" ])
383- assert mock_commands_user .call_count == 0
455+ assert mock_commands_user .call_count == 0
384456
385457
386458def test_main_user_convert_bad_account_type (mock_commands_user ):
387459 with pytest .raises (SystemExit ):
388460 main (argv = ["user" , "convert" , "username" , "account_type" ])
389- assert mock_commands_user .call_count == 0
461+ assert mock_commands_user .call_count == 0
390462
391463
392464def test_main_user_delete (mock_commands_user ):
@@ -412,7 +484,7 @@ def test_main_user_delete_force(mock_commands_user):
412484def test_main_user_delete_no_username (mock_commands_user ):
413485 with pytest .raises (SystemExit ):
414486 main (argv = ["user" , "delete" ])
415- assert mock_commands_user .call_count == 0
487+ assert mock_commands_user .call_count == 0
416488
417489
418490def test_main_user_offboard (mock_commands_user ):
@@ -458,7 +530,7 @@ def test_main_user_offboard_with_alias(mock_commands_user):
458530def test_main_user_offboard_no_username (mock_commands_user ):
459531 with pytest .raises (SystemExit ):
460532 main (argv = ["user" , "offboard" ])
461- assert mock_commands_user .call_count == 0
533+ assert mock_commands_user .call_count == 0
462534
463535
464536def test_main_user_reset (mock_commands_user ):
@@ -504,7 +576,7 @@ def test_main_user_reset_force(mock_commands_user):
504576def test_main_user_reset_no_username (mock_commands_user ):
505577 with pytest .raises (SystemExit ):
506578 main (argv = ["user" , "reset" ])
507- assert mock_commands_user .call_count == 0
579+ assert mock_commands_user .call_count == 0
508580
509581
510582def test_main_user_restore (mock_commands_user ):
@@ -518,7 +590,7 @@ def test_main_user_restore(mock_commands_user):
518590def test_main_user_restore_no_username (mock_commands_user ):
519591 with pytest .raises (SystemExit ):
520592 main (argv = ["user" , "restore" ])
521- assert mock_commands_user .call_count == 0
593+ assert mock_commands_user .call_count == 0
522594
523595
524596def test_main_user_signout (mock_commands_user ):
@@ -544,7 +616,7 @@ def test_main_user_signout_force(mock_commands_user):
544616def test_main_user_signout_no_username (mock_commands_user ):
545617 with pytest .raises (SystemExit ):
546618 main (argv = ["user" , "signout" ])
547- assert mock_commands_user .call_count == 0
619+ assert mock_commands_user .call_count == 0
548620
549621
550622@pytest .mark .e2e
0 commit comments