From 5f0e6bf18c2f74d20b78b9ccdca01e8f11b6b4f1 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 25 Sep 2021 14:37:33 +0100 Subject: [PATCH] Add tests for debug commands Closes #53 --- testsuite/yamatests/test_debug.py | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 testsuite/yamatests/test_debug.py diff --git a/testsuite/yamatests/test_debug.py b/testsuite/yamatests/test_debug.py new file mode 100644 index 0000000..c671571 --- /dev/null +++ b/testsuite/yamatests/test_debug.py @@ -0,0 +1,53 @@ +import subprocess +from pathlib import Path +from tempfile import TemporaryDirectory +from unittest import TestCase + +from helpers.datman_helpers import set_up_simple_datman +from helpers.yama_helpers import set_up_simple_yama + + +class TestYamaDebug(TestCase): + def test_rmp_fails_if_not_exists(self): + td = TemporaryDirectory("test_rmp_fails_if_not_exists") + tdpath = Path(td.name) + + datman_path = tdpath.joinpath("datman") + yama_path = datman_path.joinpath("main") + + set_up_simple_datman(datman_path) + set_up_simple_yama(yama_path) + + proc = subprocess.Popen( + ("yama", "debug", "rmp", "some_pointer_that_dont_exist"), + cwd=yama_path, + stderr=subprocess.PIPE, + ) + stderr_data = proc.stderr.read() + proc.stderr.close() + proc.wait() + self.assertNotEqual(proc.returncode, 0) + self.assertIn(b"does not exist so can not be deleted", stderr_data) + + td.cleanup() + + def test_lsp_fails_if_not_in_pile(self): + td = TemporaryDirectory("test_lsp_fails_if_not_in_pile") + tdpath = Path(td.name) + + datman_path = tdpath.joinpath("datman") + yama_path = datman_path.joinpath("main") + + set_up_simple_datman(datman_path) + set_up_simple_yama(yama_path) + + proc = subprocess.Popen( + ("yama", "debug", "lsp"), cwd=yama_path.parent, stderr=subprocess.PIPE + ) + stderr_data = proc.stderr.read() + proc.stderr.close() + proc.wait() + self.assertNotEqual(proc.returncode, 0) + self.assertIn(b"yama.toml does not exist here", stderr_data) + + td.cleanup()