From 8fe569b650ae2ca9a967abe768c77071a8a58320 Mon Sep 17 00:00:00 2001
From: Adriaan de Beer <adriaan@spaceadvisory.com>
Date: Wed, 30 Sep 2020 10:59:06 +0000
Subject: [PATCH] ST-456 added scenario for testing itango session but marking
 it skipped - not working. Also renamed a feature file for testing tools

---
 post-deployment/features/tango_admin.feature |  4 ---
 post-deployment/features/tango_tools.feature | 12 +++++++
 post-deployment/tests/test_tango_admin.py    | 34 ------------------
 post-deployment/tests/test_tango_tools.py    | 38 ++++++++++++++++++++
 4 files changed, 50 insertions(+), 38 deletions(-)
 delete mode 100644 post-deployment/features/tango_admin.feature
 create mode 100644 post-deployment/features/tango_tools.feature
 delete mode 100644 post-deployment/tests/test_tango_admin.py
 create mode 100644 post-deployment/tests/test_tango_tools.py

diff --git a/post-deployment/features/tango_admin.feature b/post-deployment/features/tango_admin.feature
deleted file mode 100644
index 5d9c68d2..00000000
--- 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 00000000..2708c82c
--- /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 5d48bbb0..00000000
--- 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 00000000..d3ab3901
--- /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')
-- 
GitLab