Resolve "Create More Robot Test for ApiStatus"

Closes #103 (closed)

Merge request reports

Loading
+1531 −54

File changed.

Preview size limit exceeded, changes collapsed.

+79 −2
Changes for tests/libraries/api_publish_service/bodyRequests.py: 79 added lines, 2 removed lines.
Original line number Diff line number Diff line
def create_service_api_description(api_name="service_1", aef_id="aef_id", supported_features="0", vendor_specific_service_api_description=None, vendor_specific_aef_profile=None):
def create_service_api_description(api_name="service_1",
                                   aef_id="aef_id",
                                   supported_features="0",
                                   vendor_specific_service_api_description=None,
                                   vendor_specific_aef_profile=None,
                                   api_status=None):
    aef_ids = list()
    if isinstance(aef_id, list):
        aef_ids = aef_id
@@ -39,6 +44,16 @@ def create_service_api_description(api_name="service_1", aef_id="aef_id", suppor
                body["aefProfiles"][0][key] = value
    if supported_features is not None:
        body['supportedFeatures'] = supported_features
    if api_status is not None:
        aef_ids_active = list()
        if isinstance(api_status, list):
            aef_ids_active = api_status
            print("api_status parameter is a list")
        elif isinstance(api_status, str):
            print("api_status parameter is a string")
            aef_ids_active.append(api_status)
        body['apiStatus'] = dict()
        body['apiStatus']['aefIds'] = aef_ids_active

    return body

@@ -52,7 +67,6 @@ def create_aef_profiles(aef_ids):
    return profiles



def create_aef_profile(aef_id, resource_name):
    data = {
        "aefId": aef_id,
@@ -86,3 +100,66 @@ def create_aef_profile(aef_id, resource_name):
        ]
    }
    return data


def create_service_api_description_patch(aef_id=None,
                                         description=None,
                                         shareable_info=None,
                                         api_status=None,
                                         service_api_category=None,
                                         api_supp_feats=None,
                                         pub_api_path=None,
                                         ccf_id=None):
    body = dict()

    # aef profiles
    aef_ids = list()
    if aef_id is None:
        aef_ids = None
    elif isinstance(aef_id, list):
        aef_ids = aef_id
        print("aef_id parameter is a list")
    elif isinstance(aef_id, str):
        print("aef_id parameter is a string")
        aef_ids.append(aef_id)
    if aef_ids is not None:
        profiles = create_aef_profiles(aef_ids)
        body['aefProfiles'] = profiles
    
    # description
    if description is not None:
        body['description'] = description

    # shareable info
    if shareable_info is not None:
        body['shareableInfo'] = shareable_info

    # service API Category
    if service_api_category is not None:
        body['serviceAPICategory'] = service_api_category

    # api Supp Feats
    if api_supp_feats is not None:
        body['apiSuppFeats'] = api_supp_feats

    # pub Api Path
    if pub_api_path is not None:
        body['pubApiPath'] = pub_api_path

    # ccf id
    if ccf_id is not None:
        body['ccfId'] = ccf_id

    # api Status
    if api_status is not None:
        aef_ids_active = list()
        if isinstance(api_status, list):
            aef_ids_active = api_status
            print("api_status parameter is a list")
        elif isinstance(api_status, str):
            print("api_status parameter is a string")
            aef_ids_active.append(api_status)
        body['apiStatus'] = dict()
        body['apiStatus']['aefIds'] = aef_ids_active

    return body
+21 −1
Changes for tests/libraries/common/types.json: 21 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -82,12 +82,32 @@
      "serviceAPICategory": "string",
      "apiSuppFeats": "SupportedFeatures",
      "pubApiPath": "PublishedApiPath",
      "ccfId": "string"
      "ccfId": "string",
      "apiStatus": "ApiStatus"
    },
    "regex_attributes": {
      "^vendorSpecific-(.*)": "VendorSpecificObject"
    }
  },
  "ServiceAPIDescriptionPatch": {
    "mandatory_attributes": {},
    "optional_attributes": {
      "apiStatus": "ApiStatus",
      "aefProfiles": "AefProfile",
      "description": "string",
      "shareableInfo": "ShareableInformation",
      "serviceAPICategory": "string",
      "apiSuppFeats": "SupportedFeatures",
      "pubApiPath": "PublishedApiPath",
      "ccfId": "string"
    }
  },
  "ApiStatus": {
    "mandatory_attributes": {
      "aefIds": "string"
    },
    "optional_attributes": {}
  },
  "VendorSpecificObject": {
    "Check": false
  },
+28 −1
Changes for tests/resources/common/basicRequests.robot: 28 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -785,7 +785,7 @@ Provider Default Registration

    RETURN    ${register_user_info}

Publish Service Api
Publish Service Api Request
    [Arguments]
    ...    ${register_user_info_provider}
    ...    ${service_name}=service_1
@@ -795,6 +795,7 @@ Publish Service Api
    ...    ${vendor_specific_service_api_description}=${None}
    ...    ${vendor_specific_aef_profile}=${None}
    ...    ${aef_id}=${NONE}
    ...    ${api_status}=${NONE}

    ${aef_ids}=    Create List
    IF    "${aef_id}" == "${NONE}"
@@ -824,6 +825,7 @@ Publish Service Api
    ...    ${supported_features}
    ...    ${vendor_specific_service_api_description}
    ...    ${vendor_specific_aef_profile}
    ...    ${api_status}
    ${resp}=    Post Request Capif
    ...    /published-apis/v1/${apf_id_to_use}/service-apis
    ...    json=${request_body}
@@ -831,6 +833,31 @@ Publish Service Api
    ...    verify=ca.crt
    ...    username=${apf_username_to_use}

    RETURN    ${resp}   ${request_body}

Publish Service Api
    [Arguments]
    ...    ${register_user_info_provider}
    ...    ${service_name}=service_1
    ...    ${apf_id}=${NONE}
    ...    ${apf_username}=${NONE}
    ...    ${supported_features}=0
    ...    ${vendor_specific_service_api_description}=${None}
    ...    ${vendor_specific_aef_profile}=${None}
    ...    ${aef_id}=${NONE}
    ...    ${api_status}=${NONE}

    ${resp}  ${request_body}=  Publish Service Api Request
    ...    ${register_user_info_provider}
    ...    ${service_name}
    ...    ${apf_id}
    ...    ${apf_username}
    ...    ${supported_features}
    ...    ${vendor_specific_service_api_description}
    ...    ${vendor_specific_aef_profile}
    ...    ${aef_id}
    ...    ${api_status}

    Check Response Variable Type And Values    ${resp}    201    ServiceAPIDescription
    Dictionary Should Contain Key    ${resp.json()}    apiId
    ${resource_url}=    Check Location Header    ${resp}    ${LOCATION_PUBLISH_RESOURCE_REGEX}
+5 −1
Changes for tests/resources/common/expectedMessages.robot: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ Create Expected Events For Service API Notifications
        END
    END

    IF   "${service_api_available_resources}" != "${NONE}"
        FOR    ${service_api_available_resource}    IN    @{service_api_available_resources}
            Log    ${service_api_available_resource}
            ${api_id}=    Fetch From Right    ${service_api_available_resource.path}    /
@@ -89,7 +90,9 @@ Create Expected Events For Service API Notifications
            ...    serviceAPIDescriptions=${service_api_description_to_use}
            Append To List    ${events_expected}    ${event_expected}
        END
    END

    IF   "${service_api_unavailable_resources}" != "${NONE}"
        FOR    ${service_api_unavailable_resource}    IN    @{service_api_unavailable_resources}
            Log    ${service_api_unavailable_resource}
            ${api_id}=    Fetch From Right    ${service_api_unavailable_resource.path}    /
@@ -103,6 +106,7 @@ Create Expected Events For Service API Notifications
            ...    serviceAPIDescriptions=${service_api_description_to_use}
            Append To List    ${events_expected}    ${event_expected}
        END
    END

    RETURN    ${events_expected}

@@ -213,7 +217,7 @@ Create Expected Service Update Event
    IF    "${event_detail_expected}" != "${TRUE}"
        ${service_api_descriptions}=    Set Variable    ${NONE}
    END
    ${events_expected}=    Create List

    ${event_expected}=    Create Notification Event
    ...    ${subscription_id}
    ...    SERVICE_API_UPDATE
Loading
Loading