Commit 6934e88f authored by Ranim Naimi's avatar Ranim Naimi
Browse files

added new test case to other documentation generating files

parent 9009c9cd
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -6,8 +6,8 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Suite Setup         Setup Entities
Suite Teardown      Delete Entities
Suite Setup         Setup Initial Entities
Suite Teardown      Delete Initial Entities
Test Template       Check that the total number of matching results is returned if the count parameter is set to true


@@ -38,9 +38,9 @@ Check that the total number of matching results is returned if the count paramet
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    ${expected_status_code}    ${response.status_code}
    Check Response Headers Containing NGSILD-Results-Count    ${expected_count}    ${response.headers}
    Check Response Headers Containing NGSILD-Results-Count Equals To    ${expected_count}    ${response.headers}

Setup Entities
Setup Initial Entities
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
@@ -56,6 +56,6 @@ Setup Entities
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}

Delete Entities
Delete Initial Entities
    Delete Entity by Id    ${first_entity_id}
    Delete Entity by Id    ${second_entity_id}
+17 −1
Original line number Diff line number Diff line
@@ -105,7 +105,9 @@ class Checks:
            'Check Response Reason set to':
                Checks.check_response_reason_set_to,
            'Check Response Does Not Contain Body':
                Checks.check_response_does_not_contain_body
                Checks.check_response_does_not_contain_body,
            'Check Response Headers Containing NGSILD-Results-Count Equals To' :
                Checks.check_response_header_contains_ngsild_results_count_equals_to,
        }

        self.args = {
@@ -303,6 +305,11 @@ class Checks:
                'params': ['response'],
                'position': [0]
            }
            ,
            'Check Response Headers Containing NGSILD-Results-Count Equals To': {
                'params': ['expected_result_count' , 'response_headers'],
                'position': [0, 1]
            }
        }

    @staticmethod
@@ -871,6 +878,14 @@ class Checks:
        else:
            raise Exception(f"ERROR, Expected 'expected_value' and 'obtained_value' parameters but received: '{kwargs}'")

    @staticmethod
    def check_response_header_contains_ngsild_results_count_equals_to(kwargs: list) -> str:
        if "ngsild_results_count" in kwargs:
            ngsild_results_count = kwargs['ngsild_results_count']
            return f'Response Header: NGSILD-Results-Count equals to {ngsild_results_count}'
        else:
            raise Exception(f'ERROR, Expected ngsild_results_count but received: {kwargs}')

    def get_checks(self, **kwargs) -> str:
        checking = None

@@ -977,6 +992,7 @@ if __name__ == "__main__":
                           'Check Created Resources Set To']
                          , status_code=201))
    print()
    print(data.get_checks(checks='Check Response Headers Containing NGSILD-Results-Count Equals To'))

    # Check exceptions
    try:
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ class InitialSetup:
            'Setup Initial Context Source Registration Subscription': InitialSetup.init_csr_sub(),
            'Setup Initial Context Source Registration Subscriptions': InitialSetup.init_csr_subs(),
            'Create Initial Context Source Registration and Mock Server': InitialSetup.init_csr_and_server(),
            'Setup Entities' : InitialSetup.init_entities(),
        }

        self.total_files = -1
+5 −3
Original line number Diff line number Diff line
@@ -1131,7 +1131,7 @@ class Requests:
        expected_parameters = ['entity_ids', 'entity_types', 'accept',
                               'attrs', 'context', 'geoproperty',
                               'options', 'limit', 'entity_id_pattern',
                               'georel', 'coordinates', 'geometry']
                               'georel', 'coordinates', 'geometry', 'count' , 'q']

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Get Entities Request:"
@@ -1160,8 +1160,10 @@ class Requests:
                    response = f"{response} and\n    Query Parameter: georel set to '{value}'"
                case 'coordinates':
                    response = f"{response} and\n    Query Parameter: coordinates set to '{value}'"
                case 'geometry':
                    response = f"{response} and\n    Query Parameter: geometry set to '{value}'"
                case 'count':
                    response = f"{response} and\n    Query Parameter: count set to '{value}'"
                case 'q':
                    response = f"{response} and\n    Query Parameter: q set to '{value}'"
                case _:
                    raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are "
                                    f"'{expected_parameters}', but received: {kwargs}")
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ Check Response Headers Containing URI set to
        ...    ignore_order=True
    END

Check Response Headers Containing NGSILD-Results-Count
Check Response Headers Containing NGSILD-Results-Count Equals To
    [Arguments]    ${expected_result_count}    ${response_headers}
    Should Be Equal    ${response_headers['NGSILD-Results-Count']}    ${expected_result_count}