From 2c9af76b884f074e5cba48565a60cb8b262222a7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 21 Dec 2018 14:02:27 +0000 Subject: [PATCH] Add tests for commands working directories --- tests/test_project/test_cli.py | 6 ++++++ tests/test_worker/test_server.py | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/tests/test_project/test_cli.py b/tests/test_project/test_cli.py index ae66f98..9ed286e 100644 --- a/tests/test_project/test_cli.py +++ b/tests/test_project/test_cli.py @@ -22,3 +22,9 @@ class ProjectRunCLITestCase(BaseTestCase): self.assertIn(str(self.project.root), env["PATH"]) for path in self.project.get_extra_path(): self.assertIn(str(path), env["PATH"]) + + def test_sets_working_dir(self): + with self.in_example_dir(): + result = self.run_cli(["project", "run", "pwd"], catch_exceptions=False) + self.assertEqual(result.exit_code, 0) + self.assertEqual(result.stdout.strip(), str(self.project.root)) diff --git a/tests/test_worker/test_server.py b/tests/test_worker/test_server.py index a86e99a..bf9c7fc 100644 --- a/tests/test_worker/test_server.py +++ b/tests/test_worker/test_server.py @@ -55,6 +55,14 @@ class ProcessWorkerTestCase(BaseWorkerTestCase): for path in self.project.get_extra_path(): self.assertIn(str(path), path_dirs) + def test_sets_working_dir(self): + response = send_to_server( + PayloadType.PROCESS, + {"path": str(self.project.root), "process": str(self.process.name)}, + ) + cwd = psutil.Process(response["pid"]).cwd() + self.assertEqual(cwd, str(self.project.root)) + def test_process_restart(self): response = send_to_server( PayloadType.PROCESS,