tests: Test filenames with spaces in them

Add two tests that check if Dangerzone properly handles input and output
filenames with spaces in them. Previously this was not straight-forward
because we didn't tokenize arguments, which lead to Click splitting
filenames with spaces in two.
This commit is contained in:
Alex Pyrgiotis 2022-10-19 18:16:45 +03:00
parent 51d4fb04c8
commit ae67dfa5a9
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -16,7 +16,6 @@ from dangerzone.cli import cli_main, display_banner
from . import TestBase, for_each_doc from . import TestBase, for_each_doc
# TODO --output-filename with spaces
# TODO explore any symlink edge cases # TODO explore any symlink edge cases
# TODO simulate ctrl-c, ctrl-d, SIGINT/SIGKILL/SIGTERM... (man 7 signal), etc? # TODO simulate ctrl-c, ctrl-d, SIGINT/SIGKILL/SIGTERM... (man 7 signal), etc?
# TODO validate output PDFs https://github.com/pdfminer/pdfminer.six # TODO validate output PDFs https://github.com/pdfminer/pdfminer.six
@ -165,6 +164,13 @@ class TestCliConversion(TestCliBasic):
) )
result.assert_success() result.assert_success()
def test_output_filename_spaces(self):
temp_dir = tempfile.mkdtemp(prefix="dangerzone-")
result = self.run_cli(
[self.sample_doc, "--output-filename", f"{temp_dir}/safe space.pdf"]
)
result.assert_success()
def test_output_filename_new_dir(self): def test_output_filename_new_dir(self):
result = self.run_cli( result = self.run_cli(
[self.sample_doc, "--output-filename", "fake-directory/my-output.pdf"] [self.sample_doc, "--output-filename", "fake-directory/my-output.pdf"]
@ -184,6 +190,7 @@ class TestCliConversion(TestCliBasic):
[ [
"“Curly_Quotes”.pdf", # issue 144 "“Curly_Quotes”.pdf", # issue 144
"Оригинал.pdf", "Оригинал.pdf",
"spaces test.pdf",
], ],
) )
def test_filenames(self, filename): def test_filenames(self, filename):