Skip to content

Commit

Permalink
shorten success output, closes #17 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorSheehan1 authored Mar 22, 2021
1 parent de120cd commit a453745
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ def __call__(self):
shutil.move(screenshot_to_copy, self.dst)
# no need for else, should be handled above by `if cmd not in accepted_cmds:`
if not self.quiet:
screenshot_names = [os.path.basename(v) for v in self.screenshots_to_copy]
self.console.print(
f"{commands[cmd]} the following files to {self.dst} successfully!\n{self.screenshots_to_copy}",
f"{commands[cmd]} the following files from {self.screenshot_dir} to {self.dst} successfully!\n{screenshot_names}",
style="green",
)
except Exception as e:
Expand Down
14 changes: 9 additions & 5 deletions tests/unit/test_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_default_args(self, check_output_mock, copy_mock, glob_mock):

s()
s.console.print.assert_called_with(
"Copied the following files to . successfully!\n['/tmp/tests/first']", style="green"
"Copied the following files from /tmp/tests to . successfully!\n['first']",
style="green",
)
check_output_mock.assert_has_calls(check_output_calls)
copy_mock.assert_has_calls(copy_mock_calls)
Expand Down Expand Up @@ -131,7 +132,7 @@ def test_move(self, check_output_mock, move_mock, glob_mock):
s.console.print = MagicMock()
s()
s.console.print.assert_called_with(
"Moved the following files to . successfully!\n['/tmp/tests/first']", style="green"
"Moved the following files from /tmp/tests to . successfully!\n['first']", style="green"
)
check_output_mock.assert_has_calls(check_output_calls)
move_mock.assert_has_calls(move_mock_calls)
Expand Down Expand Up @@ -163,7 +164,10 @@ def test_not_enough_files_yes(self, check_output_mock, copy_mock, glob_mock):
copy_mock_calls = [call("/tmp/tests/1", ".")]
print_mock_calls = [
call("Warning: there are not enough files to copy with start:1, num:2", style="yellow"),
call("Copied the following files to . successfully!\n['/tmp/tests/1']", style="green"),
call(
"Copied the following files from /tmp/tests to . successfully!\n['1']",
style="green",
),
]

s = Shot(num=2, yes=True)
Expand All @@ -190,7 +194,7 @@ def test_changing_extension_yes(self, check_output_mock, copy_mock, glob_mock):
"Warning: src and dst extensions don't match. src: .txt, dst: .md", style="yellow"
),
call(
"Copied the following files to ./first.md successfully!\n['/tmp/tests/first.txt']",
"Copied the following files from /tmp/tests to ./first.md successfully!\n['first.txt']",
style="green",
),
]
Expand Down Expand Up @@ -219,7 +223,7 @@ def test_start_and_num(self, check_output_mock, copy_mock, glob_mock):
s.console.print = MagicMock()
s()
s.console.print.assert_called_with(
"Copied the following files to . successfully!\n['/tmp/tests/2', '/tmp/tests/3']",
"Copied the following files from /tmp/tests to . successfully!\n['2', '3']",
style="green",
)
check_output_mock.assert_has_calls(check_output_calls)
Expand Down

0 comments on commit a453745

Please sign in to comment.