Skip to content
{
"tp_id": "TP/NGSI-LD/CI/Cons/DISC/027_02",
"test_objective": "Check that you can retrieve a list with a detailed representation of NGSI-LD attributes",
"reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.10",
"config_id": "",
"parent_release": "v1.3.1",
"pics_selection": "PICS_5_7_10",
"keywords": [
"Setup Initial Entities",
"Delete Initial Entities"
],
"teardown": "Delete Initial Entities",
"initial_condition": "with {\n the SUT in the \"initial state\"\n}",
"test_cases": [
{
"name": "027_02_01 Retrieve Detailed Representation Of Available Attribute",
"permutation_tp_id": "TP/NGSI-LD/CI/Cons/DISC/027_02_01",
"doc": "Check that you can retrieve a list with a detailed representation of NGSI-LD attributes",
"tags": [
"5_7_10",
"ed-attr"
],
"setup": null,
"teardown": null,
"template": null,
"then": "then {\n the SUT sends a valid Response containing:\n Response Body containing an array of Attributes and\n Response Status Code set to 200\n}",
"when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/attributes/{attribute_name}'\n method set to 'GET'\n Retrieve Attribute with attributeName set to 'airQualityLevel'",
"http_verb": "GET",
"endpoint": "attributes/{attribute_name}"
}
],
"permutations": [],
"robotpath": "ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation",
"robotfile": "027_02"
}
\ No newline at end of file
from doc.analysis.generaterobotdata import GenerateRobotData from analysis.generaterobotdata import GenerateRobotData
import json from json import dump
import sys from sys import argv
from os.path import dirname, exists from os.path import dirname, exists
from os import makedirs from os import makedirs, walk
def create_json_of_robotfile(robot_path_to_be_processed: str, robot_file_to_be_processed: str):
def create_json_of_robotfile(robot_file_to_be_processed: str):
folder_test_suites = dirname(dirname(__file__)) folder_test_suites = dirname(dirname(__file__))
folder_result_path = f'{folder_test_suites}/doc/results' folder_result_path = f'{folder_test_suites}/doc/results'
result_file = f'{folder_result_path}/{robot_file_to_be_processed}.json' result_file = f'{folder_result_path}/{robot_file_to_be_processed}.json'
robot_file = f'{folder_test_suites}/TP/NGSI-LD/{robot_path_to_be_processed}/{robot_file_to_be_processed}.robot' robot_path_to_be_processed, robot_file = find_robot_file(basedir=folder_test_suites,
filename=robot_file_to_be_processed)
# Check that the folder '/results' exists and if not, create it # Check that the folder '/results' exists and if not, create it
if not exists(folder_result_path): if not exists(folder_result_path):
makedirs(folder_result_path) makedirs(folder_result_path)
try: #try:
data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites)
data.parse_robot() data.parse_robot()
info = data.get_info() info = data.get_info()
except Exception as e: #except Exception as e:
print("WHILE GENERATING ROBOT DATA:", e) # print("WHILE GENERATING ROBOT DATA:", e)
info = {} # info = dict()
info["error_while_parsing"] = True # info["error_while_parsing"] = True
info["robotpath"] = robot_path_to_be_processed
info["robotfile"] = robot_file_to_be_processed
with open(result_file, 'w') as fp: with open(result_file, 'w') as fp:
json.dump(obj=info, indent=4, fp=fp) dump(obj=info, indent=2, fp=fp)
return info return info
def find_robot_file(basedir: str, filename: str):
filename = f'{filename}.robot'
for root, dirs, files in walk(basedir):
if filename in files:
return root.replace(f'{basedir}/TP/NGSI-LD', ''), f'{root}/{filename}'
return None, None
if __name__ == "__main__": if __name__ == "__main__":
args = sys.argv[1:] # Call with the folder below /TP/NGSI-LD which contains the robot file with name args[0]
robot_path_tbp = args[0] args = argv[1:]
robot_file_tbp = args[1] robot_file_tbp = args[0]
resulting_json = create_json_of_robotfile(robot_path_tbp, robot_file_tbp) resulting_json = create_json_of_robotfile(robot_file_tbp)
print("Correctly exiting") print("Correctly exiting")
...@@ -8,9 +8,10 @@ from os import listdir, remove, makedirs ...@@ -8,9 +8,10 @@ from os import listdir, remove, makedirs
class TestCommonBehaviours(TestCase): class TestCommonBehaviours(TestCase):
def setUp(self) -> None: @classmethod
self.folder_test_suites = dirname(dirname(dirname(__file__))) def setUpClass(cls):
folder_results = f'{self.folder_test_suites}/doc/results' TestCommonBehaviours.folder_test_suites = dirname(dirname(dirname(__file__)))
folder_results = f'{TestCommonBehaviours.folder_test_suites}/doc/results'
# Check that the folder '/results' exists and if not, create it # Check that the folder '/results' exists and if not, create it
if not exists(folder_results): if not exists(folder_results):
...@@ -19,6 +20,9 @@ class TestCommonBehaviours(TestCase): ...@@ -19,6 +20,9 @@ class TestCommonBehaviours(TestCase):
# Delete the /results folder # Delete the /results folder
[remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')] [remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')]
def setUp(self) -> None:
self.folder_test_suites = dirname(dirname(dirname(__file__)))
def common_function(self, robot_file, expected_value, difference_file): def common_function(self, robot_file, expected_value, difference_file):
data = GenerateRobotData(robot_file=robot_file, data = GenerateRobotData(robot_file=robot_file,
execdir=self.folder_test_suites) execdir=self.folder_test_suites)
...@@ -39,15 +43,42 @@ class TestCommonBehaviours(TestCase): ...@@ -39,15 +43,42 @@ class TestCommonBehaviours(TestCase):
def test_043_01(self): def test_043_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/043.robot' robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/043.robot'
expected_value = f'{self.folder_test_suites}/doc/files/043_01.json' expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/043_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_043_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_043_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_044_01(self): def test_044_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_01.robot' robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/044_01.json' expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_044_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_044_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_044_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_044_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_044_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_044_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_044_04(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_04.robot'
expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_04.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_044_04.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_044_05(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_05.robot'
expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_05.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_044_05.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
#!/usr/bin/env python
from unittest import TestCase
from doc.analysis.generaterobotdata import GenerateRobotData
from json import load, dump
from deepdiff import DeepDiff
from os.path import dirname, exists
from os import listdir, remove, makedirs
class TestCIConsumptions(TestCase):
@classmethod
def setUpClass(cls):
# TODO: Test Suites checked until 019_01_01
TestCIConsumptions.folder_test_suites = dirname(dirname(dirname(__file__)))
folder_results = f'{TestCIConsumptions.folder_test_suites}/doc/results'
# Check that the folder '/results' exists and if not, create it
if not exists(folder_results):
makedirs(folder_results)
else:
# Delete the /results folder
[remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')]
def setUp(self) -> None:
self.folder_test_suites = dirname(dirname(dirname(__file__)))
def common_function(self, robot_file, expected_value, difference_file):
data = GenerateRobotData(robot_file=robot_file,
execdir=self.folder_test_suites)
data.parse_robot()
obtained_response = data.get_info()
with open(expected_value, 'r') as file:
expected_response = load(file)
result = DeepDiff(t1=obtained_response, t2=expected_response, ignore_order=True)
if len(result) != 0:
# There are some differences
with open(difference_file, 'w') as fp:
dump(obj=obtained_response, indent=2, fp=fp)
assert False, f'They are some difference between the expected and obtained dictionaries: \n {result}'
def test_027_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/027_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_027_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_027_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/027_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_027_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_025_01(self):
self.fail("(025_01) Test Suite with Test Template, not yet implemented")
def test_022_01(self):
self.fail("(022_01) Test Suite with Test Template, not yet implemented")
def test_026_01(self):
self.fail("(026_01) Test Suite with Test Template, not yet implemented")
def test_023_01(self):
self.fail("(023_01) Test Suite with Test Template, not yet implemented")
def test_024_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/024_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_024_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_024_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/024_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_024_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_01_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_01_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_01_02(self):
self.fail("(019_01_02) Problems with Request parameters")
def test_019_01_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_01_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_01_04(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_01_04.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_04.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_01_05(self):
self.fail("(019_01_05) Problems with Request parameters")
def test_019_02_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_02_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_02_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_02_02(self):
self.fail("(019_02_02) Problems with Request parameters")
def test_019_02_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_02_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_02_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_02_04(self):
self.fail("(019_02_04) Problems with Request parameters")
def test_019_02_05(self):
self.fail("(019_02_05) Problems with Request parameters")
def test_019_03_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_03_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_03_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_03_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_03_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_03_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_03_04(self):
self.fail("(019_03_04) Problems with Request parameters")
def test_019_03_05(self):
self.fail("(019_03_04) Problems with Request parameters")
def test_019_04(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_04.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_04.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
self.fail("(019_04) Problems with Request parameters, Query Entities missing options parameter")
def test_019_05(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_05.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_05.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
self.fail("(019_04) Problems with Request parameters, Query Entities missing accept parameter")
def test_019_06(self):
self.fail("(019_06) Problems with 'Check Response Body Containing Number Of Entities'")
def test_018_01_01(self):
self.fail("(018_01_01) Problems with Query Entity, context-type information used for Link information")
def test_018_01_02(self):
self.fail("(018_01_02) Problems with Query Entity")
def test_018_01_03(self):
self.fail("(018_01_03) Problems with Query Entity")
def test_018_02(self):
self.fail("(018_02) Test Suite with Test Template, not yet implemented")
def test_018_03_01(self):
self.fail("(018_03_01) Problems with Query Entity")
def test_018_03_02(self):
self.fail("(018_03_02) Problems with Query Entity")
def test_018_04(self):
self.fail("(018_04) Problems with Request parameters, Query Entity missing options parameter")
def test_018_05(self):
self.fail("(018_05) Problems with Request parameters, Query Entity missing options parameter")
def test_018_06(self):
self.fail("(018_06) Test Suite with Test Template, not yet implemented")
def test_021_01(self):
self.fail("(021_01) Test Suite with Test Template, not yet implemented")
def test_021_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/021_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_021_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_021_03(self):
self.fail("(021_03) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_04(self):
self.fail("(021_04) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_05(self):
self.fail("(021_05) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_06(self):
self.fail("(021_06) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_07(self):
self.fail("(021_07) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_08(self):
self.fail("(021_08) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_09(self):
self.fail("(021_09) Test Suite with Test Template, not yet implemented")
def test_021_10(self):
self.fail("(021_10) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_11(self):
self.fail("(021_11) Test Suite with Test Template, not yet implemented")
def test_021_12(self):
self.fail("(021_12) Problems with Request parameters, 'Query Temporal Representation Of Entities'")
def test_021_13(self):
self.fail("(021_13) Test Suite with Test Template, not yet implemented")
def test_020_01(self):
self.fail("(020_01) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'")
def test_020_02(self):
self.fail("(020_02) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'")
def test_020_03(self):
self.fail("(020_03) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'")
def test_020_04(self):
self.fail("(020_04) Test Suite with Test Template, not yet implemented")
def test_020_05(self):
self.fail("(020_05) Test Suite with Test Template, not yet implemented")
def test_020_06(self):
self.fail("(020_06) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'")
def test_020_07(self):
self.fail("(020_07) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'")
def test_020_08(self):
self.fail("(020_08) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'")
def test_020_09(self):
self.fail("(020_09) Test Suite with Test Template, not yet implemented")
def test_020_10(self):
self.fail("(020_10) Test Suite with Test Template, not yet implemented")
#!/usr/bin/env python
from unittest import TestCase
from doc.analysis.generaterobotdata import GenerateRobotData
from json import load, dump
from deepdiff import DeepDiff
from os.path import dirname, exists
from os import listdir, remove, makedirs
class TestCIProvision(TestCase):
@classmethod
def setUpClass(cls):
TestCIProvision.folder_test_suites = dirname(dirname(dirname(__file__)))
folder_results = f'{TestCIProvision.folder_test_suites}/doc/results'
# Check that the folder '/results' exists and if not, create it
if not exists(folder_results):
makedirs(folder_results)
else:
# Delete the /results folder
[remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')]
def setUp(self) -> None:
self.folder_test_suites = dirname(dirname(dirname(__file__)))
def common_function(self, robot_file, expected_value, difference_file):
data = GenerateRobotData(robot_file=robot_file,
execdir=self.folder_test_suites)
data.parse_robot()
obtained_response = data.get_info()
with open(expected_value, 'r') as file:
expected_response = load(file)
result = DeepDiff(t1=obtained_response, t2=expected_response, ignore_order=True)
if len(result) != 0:
# There are some differences
with open(difference_file, 'w') as fp:
dump(obj=obtained_response, indent=2, fp=fp)
assert False, f'They are some difference between the expected and obtained dictionaries: \n {result}'
# def test_027_01(self):
# robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot'
# expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/027_01.json'
# difference_file = f'{self.folder_test_suites}/doc/results/out_027_01.json'
#
# self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
#
# def test_025_01(self):
# self.fail("(025_01) Test Suite with Test Template, not yet implemented")