From cf51525b1dfc97f10476d4354c34fb4b3ecc257a Mon Sep 17 00:00:00 2001 From: Nikhil Dhandre Date: Fri, 19 Apr 2019 11:19:53 +0530 Subject: [PATCH] configured miqsel test Signed-off-by: Nikhil Dhandre --- tests/conftest.py | 18 ++++++++++++++++++ tests/test_status.py | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..7fd5e02 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,18 @@ +import os +from subprocess import Popen, PIPE + +import pytest + + +@pytest.fixture(scope="module") +def config(): + """Configured miqsel""" + if not os.path.isdir("conf"): + os.mkdir("conf") + path = os.path.join(os.getcwd(), "conf") + proc = Popen(["miqsel", "config"], stdin=PIPE, stdout=PIPE) + input = str.encode("{}\n\n\n\n\n".format(path)) + proc.communicate(input=input) + yield + if os.path.isdir("conf"): + os.rmdir("conf") diff --git a/tests/test_status.py b/tests/test_status.py index 1c82d0a..e5a5f57 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -1,3 +1,4 @@ +import os import subprocess @@ -27,9 +28,16 @@ def test_miqsel_help(): def test_miqsel_unconfigured(): """Check Status of unconfigured miqsel""" + os.system("rm -rf ~/.config/miqsel/conf.yml") out, err, returncode = miqsel_cmd("miqsel status") assert returncode == 0 assert ( out.strip() == "Please run command from project directory or set project directory with config" ) + + +def test_miqsel_configured(config): + out, err, returncode = miqsel_cmd("miqsel status") + assert returncode == 0 + assert out.strip() == "Not running..."