From 77d58b82a016f2b6a2e0de0a14bad548ea355c17 Mon Sep 17 00:00:00 2001 From: FemtosecondLaser <38204088+FemtosecondLaser@users.noreply.github.com> Date: Tue, 26 Oct 2021 11:17:52 +0100 Subject: [PATCH] Added an integration test covering the following scenario: On start, if download dir is non-writable - daemon terminates with a helpful message. --- tests/integration/other/test_cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/other/test_cli.py b/tests/integration/other/test_cli.py index 7de635fc6..968665333 100644 --- a/tests/integration/other/test_cli.py +++ b/tests/integration/other/test_cli.py @@ -1,4 +1,6 @@ import contextlib +import os +import tempfile from io import StringIO from lbry.testcase import AsyncioTestCase @@ -37,3 +39,9 @@ class CLIIntegrationTest(AsyncioTestCase): cli.main(["--api", "localhost:5299", "status"]) actual_output = actual_output.getvalue() self.assertIn("is_running", actual_output) + + def test_when_download_dir_non_writable_on_start_then_daemon_dies_with_helpful_msg(self): + with tempfile.TemporaryDirectory() as download_dir: + os.chmod(download_dir, mode=0o555) # makes download dir non-writable, readable and executable + with self.assertRaisesRegex(PermissionError, f"The following directory is not writable: {download_dir}"): + cli.main(["start", "--download-dir", download_dir])