Commit 7ec25ae3 authored by lopezaguilar's avatar lopezaguilar
Browse files

Resolved issues for 044_02 and 044_03

parent f48b98b5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ ${subscription_fragment}= subscriptions/fragments/subscription-update-samp


*** Test Cases ***
044_01_01_endpoint /entities/{entityId}/attrs/{attrId}
044_01_01 endpoint /entities/{entityId}/attrs/{attrId}
    [Documentation]    Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type
    [Tags]    ea-partial-update    6_3_4
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
@@ -35,7 +35,7 @@ ${subscription_fragment}= subscriptions/fragments/subscription-update-samp
    Check Response Status Code    204    ${response.status_code}
    [Teardown]    Delete Entity by Id    ${entity_id}

044_01_02_endpoint /subscriptions/{subscriptionId}
044_01_02 endpoint /subscriptions/{subscriptionId}
    [Documentation]    Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type
    [Tags]    sub-update    6_3_4
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
+4 −4
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ ${content_type}= application/json


*** Test Cases ***
044_02_01_endpoint /entities/{entityId}
044_02_01 endpoint /entities/{entityId}
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/entities/{entityId})
    [Tags]    e-query    6_3_4
    ${id}=    Generate Random Entity Id    ${building_id_prefix}
@@ -36,7 +36,7 @@ ${content_type}= application/json
    Check Response Headers Link Not Empty    ${response.headers}
    [Teardown]    Delete Entity by Id Returning Response    ${id}

044_02_02_endpoint /subscriptions/{subscriptionId}
044_02_02 endpoint /subscriptions/{subscriptionId}
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/subscriptions/{subscriptionId})
    [Tags]    sub-retrieve    6_3_4
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
@@ -48,7 +48,7 @@ ${content_type}= application/json
    Check Response Headers Link Not Empty    ${response.headers}
    [Teardown]    Delete Subscription    ${id}

044_02_03_endpoint /csourceRegistrations/
044_02_03 endpoint /csourceRegistrations/
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/csourceRegistrations/)
    [Tags]    csr-query    6_3_4
    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
@@ -66,7 +66,7 @@ ${content_type}= application/json
    Check Response Headers Link Not Empty    ${response.headers}
    [Teardown]    Delete Context Source Registration    ${registration_id}

044_02_04_endpoint /temporal/entities
044_02_04 endpoint /temporal/entities
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/temporal/entities)
    [Tags]    te-query    6_3_4
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${tea_id_prefix}
+6 −6
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ ${content_type}= application/xml


*** Test Cases ***
044_03_01_endpoint patch /entities/{entityId}/attrs/{attrId}
044_03_01 endpoint patch /entities/{entityId}/attrs/{attrId}
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /entities/{entityId}/attrs/{attrId})
    [Tags]    ea-partial-update    6_3_4
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
@@ -39,7 +39,7 @@ ${content_type}= application/xml
    Check Response Status Code    415    ${response.status_code}
    [Teardown]    Delete Entity by Id Returning Response    ${entity_id}

044_03_02_endpoint patch /subscriptions/{subscriptionId}
044_03_02 endpoint patch /subscriptions/{subscriptionId}
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /subscriptions/{subscriptionId})
    [Tags]    sub-update    6_3_4
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
@@ -49,7 +49,7 @@ ${content_type}= application/xml
    Check Response Status Code    415    ${response.status_code}
    [Teardown]    Delete Subscription    ${id}

044_03_03_endpoint post /entities/
044_03_03 endpoint post /entities/
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entities/)
    [Tags]    e-create    6_3_4
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
@@ -60,7 +60,7 @@ ${content_type}= application/xml
    Check Response Status Code    415    ${response.status_code}
    [Teardown]    Delete Entity by Id    ${entity_id}

044_03_04_endpoint post /subscriptions/
044_03_04 endpoint post /subscriptions/
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /subscriptions/)
    [Tags]    sub-create    6_3_4
    ${subscriptions_id}=    Generate Random Entity Id    ${subscription_id_prefix}
@@ -68,7 +68,7 @@ ${content_type}= application/xml
    Check Response Status Code    415    ${response.status_code}
    [Teardown]    Delete Subscription    ${subscriptions_id}

044_03_05_endpoint post /entityOperations/create
044_03_05 endpoint post /entityOperations/create
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entityOperations/create)
    [Tags]    be-create    6_3_4
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
@@ -81,7 +81,7 @@ ${content_type}= application/xml
    Check Response Status Code    415    ${response.status_code}
    [Teardown]    Batch Delete Entities    @{expected_entities_ids}

044_03_06_endpoint post /temporal/entities/
044_03_06 endpoint post /temporal/entities/
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /temporal/entities/)
    [Tags]    te-create    6_3_4
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${tea_id_prefix}
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ class Checks:
            },
            'Check Response Headers Containing Content-Type set to': {
                'params': ['content_type'],
                'position': []
                'position': [1]
            },
            'Check Response Body Containing an Attribute set to': {
                'params': ['attribute_name'],
+14 −8
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@ from os.path import dirname
from robot.api import TestSuiteBuilder
from doc.analysis.parserobotfile import ParseRobotFile
from doc.analysis.parseapiutilsfile import ParseApiUtilsFile
from doc.analysis.parsevariablesfile import ParseVariablesFile
import re


class GenerateRobotData:
    def __init__(self, robot_file: str, execdir: str):
        self.robot = ParseRobotFile(filename=robot_file, execdir=execdir)
        self.config_variables = ParseVariablesFile()
        self.robot = ParseRobotFile(filename=robot_file, execdir=execdir, config_file=self.config_variables)
        self.apiutil = ParseApiUtilsFile(filename=self.robot.resource_file)
        self.robot.set_apiutils(self.apiutil)

@@ -66,15 +68,17 @@ class GenerateRobotData:

        return keys_with_different_values

    def get_params(self, string: str):
    def get_params(self, test_case: str):
        # New content
        test_case = self.robot.test_cases[string]
        # test_case = self.robot.test_cases[string]

        lines_starting_response = re.findall(r'^\s*\$\{response\}.*', test_case, re.MULTILINE)

        # If there is more than one line, it means that the test case has several operations, all of them to
        # create the environment content to execute the last one, which is the correct one to test the Test Case
        if len(lines_starting_response) > 1:
            # The last one corresponds to the execution of the test, the rest corresponds to the initial condition of
            # test case...
            response_to_check = lines_starting_response[-1]
        else:
            response_to_check = lines_starting_response[0]
@@ -102,8 +106,8 @@ class GenerateRobotData:
                    break
        else:
            # the attributes are in the same line
            regex = r"\s*\$\{response\}=\s{4}(.*)\n"
            matches = re.finditer(regex, string, re.MULTILINE)
            regex = r"\s*\$\{response\}=\s{4}(.*)"
            matches = re.finditer(regex, response_to_check, re.MULTILINE)
            request = aux[0].split('    ')[2]

            # We have two options from here, or the parameters are defined in the same line or the parameters are defined in
@@ -115,16 +119,18 @@ class GenerateRobotData:

                    # Get the list of keys
                    params = aux.split('    ')[1:]
                    print(params)
                else:
                    raise Exception(f"Error, unexpected format, received: '{string}'")
                    raise Exception(f"Error, unexpected format, received: '{response_to_check}'")

        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.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(string=test)
        request, params = self.get_params(test_case=string)

        #self.check_header_parameters(params=params, test=test)

Loading