From d7d37f621116c6d639254d4a6af3b8a5b4282b74 Mon Sep 17 00:00:00 2001
From: Adriaan de Beer <adriaan@spaceadvisory.com>
Date: Thu, 1 Oct 2020 16:38:21 +0000
Subject: [PATCH] ST-456 upgraded REST tests

---
 post-deployment/features/tango_tools.feature | 4 +++-
 post-deployment/tests/test_tango_tools.py    | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/post-deployment/features/tango_tools.feature b/post-deployment/features/tango_tools.feature
index cac0436e..74ea3422 100644
--- a/post-deployment/features/tango_tools.feature
+++ b/post-deployment/features/tango_tools.feature
@@ -14,4 +14,6 @@ Scenario: Test starting itango session
 Scenario: Test REST interface
   Given the TANGO_HOST is defined in the environment
   When I make a request with user tango-cs:tango to http://tango-base-tango-rest:8080/tango/rest/rc4/hosts/TANGO_HOST/10000/devices/sys/tg_test/1/attributes/boolean_scalar/value
-  Then the return code is 200
\ No newline at end of file
+  Then the return code is 200
+  And the result quality is ATTR_VALID
+  And the result name is boolean_scalar
\ No newline at end of file
diff --git a/post-deployment/tests/test_tango_tools.py b/post-deployment/tests/test_tango_tools.py
index 8591669d..d042dd6d 100644
--- a/post-deployment/tests/test_tango_tools.py
+++ b/post-deployment/tests/test_tango_tools.py
@@ -41,6 +41,7 @@ def curl_rest(run_context, basic_auth, address):
 
     pytest.result = requests.get(url, auth=auth_tuple)
     logging.info("Result text: {}".format(pytest.result.text))
+    logging.info("Result json: {}".format(pytest.result.json()))
 
 
 @then(parsers.parse('the return code is {expected_result}'))
@@ -49,8 +50,14 @@ def check_return_code(expected_result):
     # return_code = call_command.returncode
     if expected_result == '200':
         assert pytest.result.status_code == int(expected_result), "Curl returned {}, expected {}".format(pytest.result, expected_result)
+        assert pytest.result.json()['quality'] == 'ATTR_VALID'
     else:
         return_code = pytest.result.returncode
         assert str(return_code) == str(expected_result), "Function returned {}, expected {}".format(pytest.result, expected_result)
 
+@then(parsers.parse('the result {key} is {value}'))
+def check_result(key,value):
+    """result is as expected"""
+    assert pytest.result.json()[key] == value
+
 scenarios('../features/tango_tools.feature')
-- 
GitLab