From c7bb0ec546c41fdc81f549800f22afb836e836d7 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 11 Nov 2019 11:51:14 +0100 Subject: [PATCH] mgr/ssh: add make check integration Signed-off-by: Sebastian Wagner --- src/pybind/mgr/ssh/__init__.py | 7 ++++++- src/pybind/mgr/ssh/tests/__init__.py | 0 src/pybind/mgr/ssh/tests/test_ssh.py | 15 +++++++++++++++ src/pybind/mgr/tox.ini | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/pybind/mgr/ssh/tests/__init__.py create mode 100644 src/pybind/mgr/ssh/tests/test_ssh.py diff --git a/src/pybind/mgr/ssh/__init__.py b/src/pybind/mgr/ssh/__init__.py index 3f41e016e73f4..cb88e7fe1d35f 100644 --- a/src/pybind/mgr/ssh/__init__.py +++ b/src/pybind/mgr/ssh/__init__.py @@ -1 +1,6 @@ -from .module import SSHOrchestrator +import os + +if 'UNITTEST' in os.environ: + import tests + +from .module import SSHOrchestrator \ No newline at end of file diff --git a/src/pybind/mgr/ssh/tests/__init__.py b/src/pybind/mgr/ssh/tests/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/pybind/mgr/ssh/tests/test_ssh.py b/src/pybind/mgr/ssh/tests/test_ssh.py new file mode 100644 index 0000000000000..639f08c92434d --- /dev/null +++ b/src/pybind/mgr/ssh/tests/test_ssh.py @@ -0,0 +1,15 @@ +from orchestrator import ServiceDescription +from ..module import SSHOrchestrator +from tests import mock + + +@mock.patch("ssh.module.SSHOrchestrator.get_ceph_option", lambda _,key: __file__) +def test_get_unique_name(): + o = SSHOrchestrator('module_name', 0, 0) + existing = [ + ServiceDescription(service_instance='mon.a') + ] + new_mon = o.get_unique_name(existing, 'mon') + assert new_mon.startswith('mon.') + assert new_mon != 'mon.a' + diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 4205dce13459f..7a516f8cae280 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -5,4 +5,4 @@ skipsdist = true [testenv] setenv = UNITTEST = true deps = -rrequirements.txt -commands = pytest --cov --cov-append --cov-report=term --doctest-modules {posargs:mgr_util.py tests/} \ No newline at end of file +commands = pytest --cov --cov-append --cov-report=term --doctest-modules {posargs:mgr_util.py tests/ ssh/} \ No newline at end of file -- 2.39.5