diff --git a/post-deployment/features/tango_admin.feature b/post-deployment/features/tango_admin.feature deleted file mode 100644 index 5d9c68d2c23f23ba038b7538a86c364cfa0db9cd..0000000000000000000000000000000000000000 --- a/post-deployment/features/tango_admin.feature +++ /dev/null @@ -1,4 +0,0 @@ -Scenario: Connect to the tango database using tango_admin - Given the TANGO_HOST is defined in the environment - When I call the tango_admin command with parameter ping-database - Then the return code is 0 \ No newline at end of file diff --git a/post-deployment/features/tango_tools.feature b/post-deployment/features/tango_tools.feature new file mode 100644 index 0000000000000000000000000000000000000000..2708c82c70a8a64668560d6c4f7da246cea3042b --- /dev/null +++ b/post-deployment/features/tango_tools.feature @@ -0,0 +1,12 @@ +Feature: Test tango tools + +Scenario: Connect to the tango database using tango_admin + Given the TANGO_HOST is defined in the environment + When I call the tango_admin command with parameter ping-database + Then the return code is 0 + +@skip +Scenario: Test starting itango session + Given the TANGO_HOST is defined in the environment + When I call the itango3 command with parameter simple-prompt + Then the return code is 0 diff --git a/post-deployment/tests/test_tango_admin.py b/post-deployment/tests/test_tango_admin.py deleted file mode 100644 index 5d48bbb0bc0a1b32b7870030063ad9b194f3deab..0000000000000000000000000000000000000000 --- a/post-deployment/tests/test_tango_admin.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -"""tango_admin.feature feature tests.""" -import tango -import logging -import pytest -import subprocess - -from pytest_bdd import given, scenario, then, when - - -@scenario('tango_admin.feature', 'Connect to the tango database using tango_admin') -def test_connect_to_the_tango_database_using_tango_admin(): - """Connect to the tango database using tango_admin.""" - - -@given('the TANGO_HOST is defined in the environment') -def the_tango_host_is_defined_in_the_environment(run_context): - """the TANGO_HOST is defined in the environment.""" - # logging.info("TANGO_HOST: {}".format(run_context.TANGO_HOST)) - assert run_context.TANGO_HOST == 'databaseds-tango-base-test:10000', "RunContext has unexpected TANGO_HOST variable: {}".format(run_context.TANGO_HOST) - - -@pytest.fixture -@when('I call the tango_admin command with parameter ping-database') -def ping_database(): - """I call the tango_admin command with parameter ping-database.""" - return subprocess.run(["tango_admin", "--ping-database", "20"]) - - -@then('the return code is 0') -def check_return_code(ping_database): - """the result is 0.""" - assert ping_database.returncode == 0, "Ping Database returned {}".format(ping_database) - diff --git a/post-deployment/tests/test_tango_tools.py b/post-deployment/tests/test_tango_tools.py new file mode 100644 index 0000000000000000000000000000000000000000..d3ab39010f22ca1d8ce2b36a5a1aed54225396c3 --- /dev/null +++ b/post-deployment/tests/test_tango_tools.py @@ -0,0 +1,38 @@ +# coding=utf-8 +"""tango_tools.feature feature tests.""" +import tango +import logging +import pytest +import subprocess + +from pytest_bdd import given, scenario, then, when, parsers, scenarios + + +@given('the TANGO_HOST is defined in the environment') +def the_tango_host_is_defined_in_the_environment(run_context): + """the TANGO_HOST is defined in the environment.""" + # logging.info("TANGO_HOST: {}".format(run_context.TANGO_HOST)) + assert run_context.TANGO_HOST == 'databaseds-tango-base-test:10000', "RunContext has unexpected TANGO_HOST variable: {}".format(run_context.TANGO_HOST) + + +# @pytest.fixture +@when(parsers.parse('I call the {command} command with parameter {parameter}')) +def call_command(command, parameter): + """I call a command with parameter.""" + + if parameter == "ping-database": + logging.info("Running command {} with param {}".format(command, parameter)) + pytest.result = subprocess.run([command, "--"+parameter, "20"]) + elif command == "itango3": + logging.info("Running command {} with param {}".format(command, parameter)) + pytest.result = subprocess.run([command, "--"+parameter]) + + +@then('the return code is 0') +def check_return_code(): + """the result is 0.""" + # return_code = call_command.returncode + return_code = pytest.result.returncode + assert return_code == 0, "Function returned {}".format(pytest.result) + +scenarios('../features/tango_tools.feature')