yama/testsuite/yamatests/test_debug.py

54 lines
1.6 KiB
Python

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