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()