Add option for passing arguments to single-file command (#691)

* Promoting singlefile timeout to env variable

* Promoting singlefile timeout to env variable

* add tests

* Add LD_SINGLEFILE_OPTIONS support

* add tests

---------

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
pettijohn
2024-04-09 11:22:14 -07:00
committed by GitHub
parent 3ffec72d3e
commit 2b342c0d56
3 changed files with 54 additions and 4 deletions

View File

@@ -51,6 +51,44 @@ class SingleFileServiceTestCase(TestCase):
with self.assertRaises(singlefile.SingeFileError):
singlefile.create_snapshot("http://example.com", self.html_filepath)
def test_create_snapshot_empty_options(self):
mock_process = mock.Mock()
mock_process.wait.return_value = 0
self.create_test_file()
with mock.patch("subprocess.Popen") as mock_popen:
singlefile.create_snapshot("http://example.com", self.html_filepath)
expected_args = [
"single-file",
"http://example.com",
self.html_filepath + ".tmp",
]
mock_popen.assert_called_with(expected_args, start_new_session=True)
@override_settings(
LD_SINGLEFILE_OPTIONS='--some-option "some value" --another-option "another value" --third-option="third value"'
)
def test_create_snapshot_custom_options(self):
mock_process = mock.Mock()
mock_process.wait.return_value = 0
self.create_test_file()
with mock.patch("subprocess.Popen") as mock_popen:
singlefile.create_snapshot("http://example.com", self.html_filepath)
expected_args = [
"single-file",
"--some-option",
"some value",
"--another-option",
"another value",
"--third-option=third value",
"http://example.com",
self.html_filepath + ".tmp",
]
mock_popen.assert_called_with(expected_args, start_new_session=True)
def test_create_snapshot_default_timeout_setting(self):
mock_process = mock.Mock()
mock_process.wait.return_value = 0