Commit 83030aec authored by Giuseppe Tropea's avatar Giuseppe Tropea
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/feature/add-simplified-temporal-evolution-tests' into parsespec
parents 9579ff31 ca73830b
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can query the temporal evolution of entities with the simplified representation

Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Entities
Test Teardown       Delete Initial Entities
Test Template       Query the temporal evolution of entities


*** Variables ***
${vehicule_id_prefix}=              urn:ngsi-ld:Vehicle:
${bus_id_prefix}=                   urn:ngsi-ld:Bus:
${first_vehicle_payload_file}=      2020-08-vehicule-temporal-representation-sample.jsonld
${second_vehicle_payload_file}=     2020-09-vehicule-temporal-representation-sample.jsonld
${bus_payload_file}=                2020-08-bus-temporal-representation-sample.jsonld


*** Test Cases ***    TIMEREL    TIMEAT    EXPECTATION_FILE
021_14_01 After
    [Tags]    te-query    5_7_4
    after    2020-08-01T12:04:00Z    vehicles-temporal-representation-021-14-01-expectation.json
021_14_02 Before
    [Tags]    te-query    5_7_4
    before    2020-09-01T13:06:00Z    vehicles-temporal-representation-021-14-02-expectation.json


*** Keywords ***
Query the temporal evolution of entities
    [Documentation]    Check that you can query the temporal evolution of entities with the simplified representation
    [Arguments]    ${timerel}    ${timeat}    ${expectation_file}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    Vehicle
    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    timerel=${timerel}
    ...    timeAt=${timeat}
    ...    context=${ngsild_test_suite_context}
    ...    options=temporalValues
    @{temporal_entities_representation_ids}=    Create List
    ...    ${first_temporal_entity_representation_id}
    ...    ${second_temporal_entity_representation_id}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing EntityTemporal elements
    ...    ${expectation_file}
    ...    ${temporal_entities_representation_ids}
    ...    ${response.json()}

Setup Initial Entities
    ${first_temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicule_id_prefix}
    ${second_temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicule_id_prefix}
    ${third_temporal_entity_representation_id}=    Generate Random Entity Id    ${bus_id_prefix}
    Create Temporal Representation Of Entity
    ...    ${first_vehicle_payload_file}
    ...    ${first_temporal_entity_representation_id}
    Create Temporal Representation Of Entity
    ...    ${second_vehicle_payload_file}
    ...    ${second_temporal_entity_representation_id}
    Create Temporal Representation Of Entity    ${bus_payload_file}    ${third_temporal_entity_representation_id}
    Set Test Variable    ${first_temporal_entity_representation_id}
    Set Test Variable    ${second_temporal_entity_representation_id}
    Set Test Variable    ${third_temporal_entity_representation_id}

Delete Initial Entities
    Delete Temporal Representation Of Entity    ${first_temporal_entity_representation_id}
    Delete Temporal Representation Of Entity    ${second_temporal_entity_representation_id}
    Delete Temporal Representation Of Entity    ${third_temporal_entity_representation_id}
+70 −0
Original line number Diff line number Diff line
[
  {
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "speed": {
      "type": "Property",
      "values": [
        [
          80.0,
          "2020-08-01T12:05:00Z"
        ],
        [
          100.0,
          "2020-08-01T12:07:00Z"
        ]
      ]
    },
    "fuelLevel": {
      "type": "Property",
      "values": [
        [
          53.0,
          "2020-08-01T13:05:00Z"
        ],
        [
          40.0,
          "2020-08-01T14:07:00Z"
        ]
      ]
    }
  },
  {
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "speed": {
      "type": "Property",
      "values": [
        [
          120.0,
          "2020-09-01T12:03:00Z"
        ],
        [
          80.0,
          "2020-09-01T12:05:00Z"
        ],
        [
          100.0,
          "2020-09-01T12:07:00Z"
        ]
      ]
    },
    "fuelLevel": {
      "type": "Property",
      "values": [
        [
          67.0,
          "2020-09-01T12:03:00Z"
        ],
        [
          53.0,
          "2020-09-01T13:05:00Z"
        ],
        [
          40.0,
          "2020-09-01T14:07:00Z"
        ]
      ]
    }
  }
]
+74 −0
Original line number Diff line number Diff line
[
  {
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "speed": {
      "type": "Property",
      "values": [
        [
          120.0,
          "2020-08-01T12:03:00Z"
        ],
        [
          80.0,
          "2020-08-01T12:05:00Z"
        ],
        [
          100.0,
          "2020-08-01T12:07:00Z"
        ]
      ]
    },
    "fuelLevel": {
      "type": "Property",
      "values": [
        [
          67.0,
          "2020-08-01T12:03:00Z"
        ],
        [
          53.0,
          "2020-08-01T13:05:00Z"
        ],
        [
          40.0,
          "2020-08-01T14:07:00Z"
        ]
      ]
    }
  },
  {
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "speed": {
      "type": "Property",
      "values": [
        [
          120.0,
          "2020-09-01T12:03:00Z"
        ],
        [
          80.0,
          "2020-09-01T12:05:00Z"
        ],
        [
          100.0,
          "2020-09-01T12:07:00Z"
        ]
      ]
    },
    "fuelLevel": {
      "type": "Property",
      "values": [
        [
          67.0,
          "2020-09-01T12:03:00Z"
        ],
        [
          53.0,
          "2020-09-01T13:05:00Z"
        ]
      ]
    }
  }
]
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ class Requests:
                'params': ['context', 'entity_types', 'entity_ids', 'entity_id_pattern',
                           'ngsild_query', 'csf', 'georel', 'geometry',
                           'coordinates', 'geoproperty', 'timerel', 'timeAt',
                           'attrs', 'limit', 'lastN', 'accept']
                           'attrs', 'limit', 'lastN', 'accept', 'options']
            },
            'Query Temporal Representation Of Entities Via Post': {
                'positions': [],
@@ -1025,7 +1025,7 @@ class Requests:
        expected_parameters = ['context', 'entity_types', 'entity_ids', 'entity_id_pattern',
                               'ngsild_query', 'csf', 'georel', 'geometry',
                               'coordinates', 'geoproperty', 'timerel', 'timeAt',
                               'attrs', 'limit', 'lastN', 'accept']
                               'attrs', 'limit', 'lastN', 'accept', 'options']

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Query Temporal Representation of Entities"
@@ -1064,6 +1064,8 @@ class Requests:
                    response = f"{response} and\n    Query Parameter: lastN set to '{value}'"
                case 'accept':
                    response = f"{response} and\n    Query Parameter: accept set to '{value}'"
                case 'options':
                    response = f"{response} and\n    Query Parameter: options set to '{value}'"

            # If an exact match is not confirmed, this last case will be used if provided
                case _:
+7 −0
Original line number Diff line number Diff line
@@ -385,6 +385,13 @@ class TestCIConsumptions(TestCase):

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_021_14(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/021_14.json'
        difference_file = f'{self.folder_test_suites}/doc/results/out_021_14.json'

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_020_01(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/020_01.json'
Loading