Skip to content
044_04.robot 3.42 KiB
Newer Older
lopesg's avatar
lopesg committed
*** Settings ***
lopesg's avatar
lopesg committed
Documentation   Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json"
lopesg's avatar
lopesg committed
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
lopesg's avatar
lopesg committed
${accept}=  application/xml
${status_code}=  406

lopesg's avatar
lopesg committed
${building_id_prefix}=  urn:ngsi-ld:Building:
lopesg's avatar
lopesg committed
${building_filename}=  building-simple-attributes-sample.jsonld

lopesg's avatar
lopesg committed
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
lopesg's avatar
lopesg committed
${subscription_filename}=  csourceSubscriptions/subscription-sample.jsonld

*** Test Cases ***
044_04_01_endpoint get /entities/{entityId}
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /entities/{entityId})
lopesg's avatar
lopesg committed
    [Tags]  cb
lopesg's avatar
lopesg committed
    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${building_filename}     ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

lopesg's avatar
lopesg committed
   ${request}    ${response}=    Query Entity    ${entity_id}    accept=${accept}
lopesg's avatar
lopesg committed
    Check Response Status Code  ${status_code}    ${response['status']}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}

044_04_02_endpoint get /subscriptions/{subscriptionId}
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /subscriptions/{subscriptionId})
lopesg's avatar
lopesg committed
    [Tags]  cb    
lopesg's avatar
lopesg committed
    ${id}=  Generate Random Entity Id    ${subscription_id_prefix}    
    ${response}=    Create Subscription    ${id}    ${subscription_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

lopesg's avatar
lopesg committed
    ${request}    ${response}=  Retrieve Subscription  ${id}    accept=${accept}
lopesg's avatar
lopesg committed
    Check Response Status Code  ${status_code}    ${response['status']}

    [Teardown]  Delete Subscription  ${id}

044_04_03_endpoint get /csourceRegistrations/
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceRegistrations/)

lopesg's avatar
lopesg committed
    ${request}    ${response}=  Query Context Source Registrations With Return  type=Building    accept=${accept}
    Check Response Status Code  ${status_code}    ${response['status']}
lopesg's avatar
lopesg committed

044_04_04_endpoint get /csourceSubscriptions/
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceSubscriptions/)
lopesg's avatar
lopesg committed
    [Tags]  cb    
lopesg's avatar
lopesg committed
    Query Context Source Registration Subscriptions  accept=${accept}
    Check Response Status Code Set To  ${status_code}

044_04_05_endpoint get /temporal/entities
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /temporal/entities)
lopesg's avatar
lopesg committed
    [Tags]  cb
    ${entity_types_to_be_retrieved}=  Catenate    SEPARATOR=,     Vehicle
lopesg's avatar
lopesg committed
    Query Temporal Representation Of Entities   entity_types=${entity_types_to_be_retrieved}    timerel=after    timeAt=2020-08-01T12:05:00Z    accept=${accept}
    Check Response Status Code Set To  ${status_code}