Skip to content
......@@ -12,7 +12,7 @@ ${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases ***
Upsert a batch of two valid entities and one invalid entity
004_05_01 Upsert a batch of two valid entities and one invalid entity
[Documentation] Check that you can upsert a batch of two valid entities and one invalid entity
[Tags] be-upsert 5_6_8
${first_entity_id}= Generate Random Entity Id ${building_id_prefix}
......
......@@ -9,9 +9,9 @@ Test Template Batch Upsert Entity With Invalid Request Scenarios
*** Test Cases *** FILENAME PROBLEM_TYPE
InvalidJson [Tags] be-upsert 5_6_8
004_06_01 InvalidJson [Tags] be-upsert 5_6_8
batch/invalid-json-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST}
InvalidJsonLd [Tags] be-upsert 5_6_8
004_06_02 InvalidJsonLd [Tags] be-upsert 5_6_8
batch/invalid-json-ld-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA}
......
......@@ -15,13 +15,13 @@ ${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases *** FILENAME CONTENT_TYPE
001_01_01_MinimalEntity
001_01_01 MinimalEntity
building-minimal-without-context-sample.jsonld application/json
001_01_02_EntityWithSimpleProperties
001_01_02 EntityWithSimpleProperties
building-simple-attributes-sample.jsonld application/ld+json
001_01_03_EntityWithRelationshipsProperties
001_01_03 EntityWithRelationshipsProperties
building-relationship-of-property-sample.jsonld application/ld+json
001_01_04_EntityWithLocationAttribute
001_01_04 EntityWithLocationAttribute
building-location-attribute-sample.jsonld application/ld+json
......@@ -40,12 +40,12 @@ Create Entity Scenarios
Check Response Headers Containing URI set to ${entity_id} ${response.headers}
${created_entity}= Load Test Sample entities/${filename} ${entity_id}
IF '${content_type}'=='application/json'
${response}= Retrieve Entity by Id ${entity_id} ${content_type}
${response}= Retrieve Entity by Id id=${entity_id} accept=${content_type}
END
IF '${content_type}'=='application/ld+json'
${response}= Retrieve Entity by Id
... ${entity_id}
... ${content_type}
... id=${entity_id}
... accept=${content_type}
... context=${ngsild_test_suite_context}
END
Check Created Resource Set To ${created_entity} ${response.json()}
......
......@@ -9,11 +9,11 @@ Test Template Create Entity With Invalid Request Scenarios
*** Test Cases *** FILENAME ERROR_TYPE
001_02_01_InvalidJson
001_02_01 InvalidJson
invalid-json-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST}
001_02_02_EmptyJson
001_02_02 EmptyJson
empty-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST}
001_02_03_EntityWithNoContext
001_02_03 EntityWithNoContext
building-minimal-without-context-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA}
......
......@@ -16,7 +16,7 @@ ${content_type}= application/ld+json
*** Test Cases ***
Create one valid entity and one invalid entity
001_03_01 Create one valid entity and one invalid entity
[Documentation] Check that you cannot create an entity with an existing id
[Tags] e-create 5_6_1
${entity_id}= Generate Random Entity Id ${building_id_prefix}
......
......@@ -5,6 +5,8 @@ Resource ${EXECDIR}/resources/ApiUtils.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Teardown Delete Initial Entity
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
......@@ -12,21 +14,26 @@ ${filename}= building-simple-attributes-sample.json
*** Test Cases ***
Create one entity using a provided Link header with JSON content type
001_04_01 Create one entity using a provided Link header with JSON content type
[Documentation] Check that the @context is obtained from a Link Header if the Content-Type header is "application/json"
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_JSON}
... context=${ngsild_test_suite_context}
${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context}
${response}= Retrieve Entity by Id id=${entity_id} context=${ngsild_test_suite_context}
# Attribute should be compacted as we used the same context as provided when creating the entity
Check Response Body Containing an Attribute set to almostFull ${response.json()}
${response}= Retrieve Entity by Id ${entity_id}
${response}= Retrieve Entity by Id id=${entity_id}
# Attribute should not be compacted as we did not provide a context containing this term
Check Response Body Containing an Attribute set to
... https://ngsi-ld-test-suite/context#almostFull
... ${response.json()}
${response}= Delete Entity by Id ${entity_id}
*** Keywords ***
Delete Initial Entity
Delete Entity by Id ${entity_id}
......@@ -5,6 +5,8 @@ Resource ${EXECDIR}/resources/ApiUtils.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Teardown Delete Initial Entity
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
......@@ -12,18 +14,30 @@ ${filename}= building-simple-attributes-sample.json
*** Test Cases ***
Create one entity using the default context with JSON content type
001_05_01 Create one entity using the default context with JSON content type and request without context
[Documentation] Check that the default @context is used if the Content-Type header is "application/json" and the Link header does not contain a JSON-LD @context
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${entity_id}
${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_JSON}
${response}= Retrieve Entity by Id ${entity_id}
${response}= Retrieve Entity by Id id=${entity_id}
# Attribute should be compacted as we used the same default context as provided when creating the entity
Check Response Body Containing an Attribute set to almostFull ${response.json()}
001_05_02 Create one entity using the default context with JSON content type and request with context
[Documentation] Check that the default @context is used if the Content-Type header is "application/json" and the Link header does not contain a JSON-LD @context
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${entity_id}
${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_JSON}
${response}= Retrieve Entity by Id
... ${entity_id}
... ${CONTENT_TYPE_JSON}
... id=${entity_id}
... accept=${CONTENT_TYPE_JSON}
... context=${ngsild_test_suite_context}
# Attribute should not be compacted as we did not provide a context containing this term
Check Response Body Containing an Attribute set to ngsi-ld:default-context/almostFull ${response.json()}
${response}= Delete Entity by Id ${entity_id}
*** Keywords ***
Delete Initial Entity
Delete Entity by Id ${entity_id}
......@@ -12,7 +12,7 @@ ${filename}= building-simple-attributes-sample.jsonld
*** Test Cases ***
Create one entity containing a JSON-LD @context with a JSON content type
001_06_01 Create one entity containing a JSON-LD @context with a JSON content type
[Documentation] Check that an HTTP error response of type BadRequestData is raised if the Content-Type header is "application/json" and the request payload body (as JSON) contains a "@context" term
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
......
......@@ -12,15 +12,15 @@ ${filename}= building-simple-attributes-sample.jsonld
*** Test Cases ***
Create one entity using a JSON-LD @context obtained from the request payload
001_07_01 Create one entity using a JSON-LD @context obtained from the request payload
[Documentation] Check that the @context is obtained from the request payload body itself if the Content-Type header is "application/ld+json"
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON}
${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context}
${response}= Retrieve Entity by Id id=${entity_id} context=${ngsild_test_suite_context}
# Attribute should be compacted as we used the same context as provided when creating the entity
Check Response Body Containing an Attribute set to almostFull ${response.json()}
${response}= Retrieve Entity by Id ${entity_id}
${response}= Retrieve Entity by Id id=${entity_id}
# Attribute should not be compacted as we did not provide a context containing this term
Check Response Body Containing an Attribute set to
... https://ngsi-ld-test-suite/context#almostFull
......
......@@ -12,7 +12,7 @@ ${filename}= building-simple-attributes-sample.json
*** Test Cases ***
Create one entity not containing a JSON-LD @context with a JSON-LD content type
001_08_01 Create one entity not containing a JSON-LD @context with a JSON-LD content type
[Documentation] Check that an HTTP error response of type BadRequestData is raised if the Content-Type header is "application/ld+json" and the request payload body does not contain a @context term
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
......
......@@ -12,7 +12,7 @@ ${filename}= building-simple-attributes-sample.jsonld
*** Test Cases ***
Create one entity with a Link header and a JSON-LD content type
001_09_01 Create one entity with a Link header and a JSON-LD content type
[Documentation] Check that an HTTP error response of type BadRequestData is raised if the Content-Type header is "application/ld+json" and a JSON-LD Link header is present in the incoming HTTP request
[Tags] e-create 6_3_5
${entity_id}= Generate Random Entity Id ${building_id_prefix}
......
......@@ -12,7 +12,7 @@ ${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases ***
Delete an entity
002_01_01 Delete an entity
[Documentation] Check that you can delete an entity by id
[Tags] e-delete 5_6_6
${entity_id}= Generate Random Entity Id ${building_id_prefix}
......@@ -23,5 +23,5 @@ Delete an entity
Check Response Status Code 201 ${response.status_code}
${response}= Delete Entity by Id Returning Response ${entity_id}
Check Response Status Code 204 ${response.status_code}
${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context}
${response}= Retrieve Entity by Id id=${entity_id} context=${ngsild_test_suite_context}
Check SUT Not Containing Resource ${response.status_code}
......@@ -10,9 +10,9 @@ Test Template Delete Entity Scenarios
*** Test Cases *** ENTITY_ID EXPECTED_STATUS_CODE PROBLEM_TYPE
002_02_01_Delete an entity if the Entity Id is not present
002_02_01 Delete an entity if the Entity Id is not present
${EMPTY} 400 ${ERROR_TYPE_BAD_REQUEST_DATA}
002_02_02_Delete an entity if the Entity Id is not a valid URI
002_02_02 Delete an entity if the Entity Id is not a valid URI
thisisaninvaliduri 400 ${ERROR_TYPE_BAD_REQUEST_DATA}
......
......@@ -13,7 +13,7 @@ ${expected_status_code}= 404
*** Test Cases ***
Delete an entity with an id not known to the system
002_03_01 Delete an entity with an id not known to the system
[Documentation] Check that you cannot delete an entity if the entity id is not known to the system
[Tags] e-delete 5_6_6
${entity_id}= Generate Random Entity Id ${building_id_prefix}
......
......@@ -55,7 +55,7 @@ Append Attributes Without Params
Check Response Status Code ${status_code} ${response.status_code}
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
Check Updated Resource Set To ${entity_expectation_payload} ${response.json()}
......@@ -86,7 +86,7 @@ Append Attributes With Params
END
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
${ignored_attributes}= Create List @context
......
......@@ -47,7 +47,7 @@ Delete Attributes
Check Response Status Code ${status_code} ${response.status_code}
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
${ignored_attributes}= Create List @context
......
......@@ -43,7 +43,7 @@ Update Attributes
Check Response Status Code ${status_code} ${response.status_code}
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
${ignored_attributes}= Create List @context
......
......@@ -47,7 +47,7 @@ Update Attributes
END
${entity_expectation_payload}= Load Test Sample entities/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
${ignored_attributes}= Create List @context
......
......@@ -77,7 +77,9 @@ class Checks:
'Check SUT Not Containing Resources':
Checks.check_sut_not_containing_resources,
'Check NotificationParams':
Checks.check_notificationparams
Checks.check_notificationparams,
'Check Response Body Containing Batch Operation Result':
Checks.check_response_body_containing_batch_operation_result
}
self.args = {
......@@ -95,7 +97,7 @@ class Checks:
},
'Check Response Body Containing an Attribute set to': {
'params': ['attribute_name'],
'position': []
'position': [1]
},
'Check Response Body Containing List Containing EntityTemporal elements': {
'params': ['filename', 'entity_ids'],
......@@ -148,6 +150,10 @@ class Checks:
'Check NotificationParams': {
'params': ['format', 'uri', 'accept', 'status', 'timesSent'],
'position': []
},
'Check Response Body Containing Batch Operation Result': {
'params': ['operation'],
'position': [1]
}
}
......@@ -390,7 +396,10 @@ class Checks:
def check_sut_not_containing_resource(kwargs: list) -> str:
if "status_code" in kwargs:
status_code = kwargs['status_code']
return f'Response Status Code set to {status_code} ({HTTPStatus(status_code).phrase})'
try:
return f'Response Status Code set to {status_code} ({HTTPStatus(status_code).phrase})'
except ValueError:
return f'Response Status Code set to {status_code}'
else:
raise Exception(f'ERROR, Expected status_code parameter but received: {kwargs}')
......@@ -417,6 +426,13 @@ class Checks:
raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
f"'{expected_parameters}', but received: {kwargs}")
@staticmethod
def check_response_body_containing_batch_operation_result(kwargs: list) -> str:
if "operation" in kwargs:
return f"Response Status Code set to '{kwargs['operation']}'"
else:
raise Exception(f'ERROR, Expected operation parameter but received: {kwargs}')
def get_checks(self, **kwargs) -> str:
checking = None
......
......@@ -136,14 +136,9 @@ class GenerateRobotData:
return request, params
def get_step_data(self, test: str):
# string = self.robot.get_substring(initial_string=test, final_string=self.suite.name, include=False)
string = self.robot.test_cases[test]
# request, params = self.get_params(string=string)
request, params = self.get_params(test_case=string)
#self.check_header_parameters(params=params, test=test)
verb, url = self.apiutil.get_response(keyword=request)
index = None
......@@ -158,9 +153,6 @@ class GenerateRobotData:
endpoint=self.test_cases[index]['endpoint'],
when=self.test_cases[index]['when'])
#expected_status_code = self.robot.get_expected_status_code(keyword='Check Response Status Code')
#self.test_cases[index]['expected_status_code'] = expected_status_code
def check_header_parameters(self, params: list, test: str):
value = str()
......