Skip to content
checks.py 50.4 KiB
Newer Older
from http import HTTPStatus


class Checks:
    def __init__(self):
        self.checks = {
lopezaguilar's avatar
lopezaguilar committed
            'Check Response Status Code':
                Checks.check_response_status_code,
            'Check Response Body Containing Array Of URIs set to':
                Checks.check_response_body_containing_array_of_uris_set_to,
            'Check Created Resources Set To':
                Checks.check_created_resources_set_to,
            'Check Response Headers Containing Content-Type set to':
                Checks.check_response_headers_containing_content_type_set_to,
            'Check Response Headers Link Not Empty':
                Checks.check_response_headers_link_not_empty,
            'Check Response Headers Containing URI set to':
                Checks.check_response_headers_containing_uri_set_to,
            'Check Response Headers ID Not Empty':
                Checks.check_response_headers_id_not_empty,
            'Check Response Body Containing an Attribute set to':
                Checks.check_response_body_containing_an_attribute_set_to,
            'Check Response Body Containing Entity element':
                Checks.check_response_body_containing_entity_element,
            'Check Response Body Containing List Containing Entity Elements':
                Checks.check_response_body_containing_list_containing_entity_elements,
            'Check Response Body Containing List Containing Entity Elements With Different Types':
                Checks.check_response_body_containing_list_containing_entity_elements_with_different_types,
            'Check Response Body Containing EntityTemporal element':
                Checks.check_response_body_containing_entitytemporal_element,
            'Check Response Body Containing List Containing EntityTemporal elements':
                Checks.check_response_body_containing_list_containing_entitytemporal_elements,
            'Check Response Body Containing Subscription element':
                Checks.check_response_body_containing_subscription_element,
            'Check Response Body Containing List Containing Subscription elements':
lopezaguilar's avatar
lopezaguilar committed
                Checks.check_response_body_containing_list_containing_subscription_elements,
            'Check Response Body Containing Number Of Entities':
                Checks.check_response_body_containing_number_of_entities,
            'Check Response Body Containing Context Source Registration element':
                Checks.check_response_body_containing_context_source_registration_element,
            'Check Response Body Containing EntityTypeList element':
                Checks.check_response_body_containing_entitytypelist_element,
            'Check Response Body Containing EntityType element':
                Checks.check_response_body_containing_entitytype_element,
            'Check Response Body Containing EntityTypeInfo element':
                Checks.check_response_body_containing_entitytypeinfo_element,
            'Check Response Body Containing AttributeList element':
lopezaguilar's avatar
lopezaguilar committed
                Checks.check_response_body_containing_attributelist_element,
            'Check Response Body Containing Attribute element':
                Checks.check_response_body_containing_attribute_element,
            'Check Response Body Containing List Containing Context Source Registrations elements':
                Checks.check_response_body_containing_list_containing_context_source_registrations_elements,
            'Check Response Body Type When Using Session Request':
                Checks.check_response_body_type_when_using_session_request,
            'Check Response Body Containing ProblemDetails Element Containing Type Element set to':
                Checks.check_response_body_containing_problemdetails_element_containing_type_element_set_to,
            'Check Response Body Title When Using Session Request':
                Checks.check_response_body_title_when_using_session_request,
            'Check Response Body Containing ProblemDetails Element Containing Title Element':
                Checks.check_response_body_containing_problemdetails_element_containing_title_element,
            'Check Response Body Containing ProblemDetails Element':
                Checks.check_response_body_containing_problemdetails_element,
lopezaguilar's avatar
lopezaguilar committed
            'Check RL Response Body Containing ProblemDetails Element Containing Type Element set to':
lopezaguilar's avatar
lopezaguilar committed
                Checks.check_rl_response_body_containing_problemdetails_element_containing_type_element_set_to,
            'Check RL Response Body Containing ProblemDetails Element Containing Title Element':
                Checks.check_rl_response_body_containing_problemdetails_element_containing_title_element,
            'Check JSON Value In Response Body':
                Checks.check_json_value_in_response_body,
            'Check Pagination Prev And Next Headers':
                Checks.check_pagination_prev_and_next_headers,
            'Check Created Resource Set To':
                Checks.check_created_resource_set_to,
            'Check Updated Resource Set To':
                Checks.check_updated_resource_set_to,
            'Check Updated Resources Set To':
                Checks.check_updated_resources_set_to,
lopezaguilar's avatar
lopezaguilar committed
            'Check SUT Not Containing Resource':
                Checks.check_sut_not_containing_resource,
            'Check SUT Not Containing Resources':
                Checks.check_sut_not_containing_resources,
            'Check NotificationParams':
lopezaguilar's avatar
lopezaguilar committed
                Checks.check_notificationparams,
            'Check Response Body Containing Batch Operation Result':
lopezaguilar's avatar
lopezaguilar committed
                Checks.check_response_body_containing_batch_operation_result,
lopezaguilar's avatar
lopezaguilar committed
            'Wait for notification':
                Checks.wait_for_notification,
            'Wait for no notification':
                Checks.wait_for_no_notification,
            'Wait for notification and validate it':
                Checks.wait_for_notification_and_validate_it,
lopezaguilar's avatar
lopezaguilar committed
            'Should be Equal':
lopezaguilar's avatar
lopezaguilar committed
                Checks.should_be_equal,
            'Dictionary Should Contain Key':
                Checks.dictionary_should_contain_key,
            'Should Not Be Empty':
                Checks.should_not_be_empty,
            'Should be True':
                Checks.should_be_true,
lopezaguilar's avatar
lopezaguilar committed
            'Check Response Body Content':
lopezaguilar's avatar
lopezaguilar committed
                Checks.check_response_body_content,
            'Check Retrieving Context Source Registration':
                Checks.check_retrieving_context_source_registration,
            'Check JSON Value Not In Response Body':
                Checks.check_json_value_not_in_response_body,
            'Check Response Reason set to':
                Checks.check_response_reason_set_to,
            '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,
lopezaguilar's avatar
lopezaguilar committed
        }

        self.args = {
            'Check Response Status Code': {
                'params': ['status_code'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [0]
            'Check Response Body Containing Array Of URIs set to': {
                'params': ['expected_entities_ids', 'response_body'],
                'position': [0, 1]
            },
            'Check Response Body Containing ProblemDetails Element Containing Type Element set to': {
                'params': ['type'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [1]
            'Check Response Body Containing ProblemDetails Element': {
                'params': ['problem_type'],
                'position': [1]
            },
            'Check Response Headers Containing Content-Type set to': {
                'params': ['content_type'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [0]
            'Check Updated Resource Set To': {
                'params': ['updated_resource', 'response_body', 'ignored_keys'],
                'position': [0]
            },
            'Check Response Body Containing ProblemDetails Element Containing Title Element': {
                'params': ['response_body'],
                'position': [0]
            },
            'Check Response Headers Containing URI set to': {
                'params': ['expected_entity_id', 'response_headers'],
                'position': [0, 1]
            },
            'Check Response Body Title When Using Session Request': {
                'params': ['response_body'],
                'position': [0]
            },
            'Check Response Body Containing EntityTypeInfo element': {
                'params': ['expectation_filename', 'response_body'],
                'position': [0, 1]
            },
            'Check Response Body Containing List Containing Entity Elements': {
                'params': ['expectation_filename', 'entities_ids', 'response_body', 'ignore_core_context_version'],
                'position': []
            },
            'Check Response Body Containing List Containing Entity Elements With Different Types': {
                'params': ['filename', 'entities_representation_ids', 'response_body', 'ignore_core_context_version'],
                'position': []
            },
            'Check Response Body Containing an Attribute set to': {
lopezaguilar's avatar
lopezaguilar committed
                'params': ['expected_attribute_name', 'response_body', 'expected_attribute_value'],
                'position': []
            'Check Response Body Containing Attribute element': {
                'params': ['expectation_filename', 'response_body'],
                'position': [0, 1]
            },
            'Check Response Body Containing EntityTemporal element': {
                'params': ['filename', 'temporal_entity_representation_id', 'response_body'],
                'position': [0, 1, 2]
            },
            'Check SUT Not Containing Resources': {
                'params': ['response_body'],
                'position': [0]
            },
            'Check Response Body Containing List Containing EntityTemporal elements': {
                'params': ['filename', 'entity_ids'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [0, 1]
            'Check RL Response Body Containing ProblemDetails Element Containing Title Element': {
                'params': ['response_body'],
                'position': [0]
            },
            'Check Response Body Containing List Containing Subscription elements': {
lopezaguilar's avatar
lopezaguilar committed
                'params': ['file', 'id', 'response'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [0, 1, 2]
            },
            'Check Response Body Containing Number Of Entities': {
lopezaguilar's avatar
lopezaguilar committed
                'params': ['entity_type', 'number_entities', 'response'],
                'position': [0, 1, 2]
            },
            'Check Response Body Containing Context Source Registration element': {
lopezaguilar's avatar
lopezaguilar committed
                'params': ['file', 'id', 'response'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [0, 1, 2]
            },
            'Check Response Body Containing EntityTypeList element': {
                'params': ['filename', 'response'],
lopezaguilar's avatar
lopezaguilar committed
                'position': [0, 1]
Loading full blame...