044_03.robot 5.26 KB
Newer Older
lopesg's avatar
lopesg committed
*** Settings ***
lopesg's avatar
lopesg committed
Documentation   Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "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
${vehicle_id_prefix}=  urn:ngsi-ld:Vehicle:
lopesg's avatar
lopesg committed
${vehicle_filename}=  vehicle-simple-attributes-sample.jsonld
lopesg's avatar
lopesg committed
${vehicle_attribute}=  speed
${vehicle_fragment}=  vehicle-brandname-fragment.jsonld
lopesg's avatar
lopesg committed

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

${tea_id_prefix}=  urn:ngsi-ld:Vehicle:
${tea_filename}=  vehicle-temporal-representation-sample.jsonld

${building_id_prefix}=  urn:ngsi-ld:Building:
${building_filename}=  building-simple-attributes-sample.jsonld

lopesg's avatar
lopesg committed
${content_type}=  application/xml

lopesg's avatar
lopesg committed
*** Test Cases ***
044_03_01_endpoint patch /entities/{entityId}/attrs/{attrId}
lopesg's avatar
lopesg committed
    [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})
lopesg's avatar
lopesg committed
    [Tags]  ea-partial-update    6_3_4
lopesg's avatar
lopesg committed

    ${entity_id}=     Generate Random Entity Id    ${vehicle_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${vehicle_filename}     ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

lopesg's avatar
lopesg committed
    ${response}=    Partial Update Entity Attributes    ${entity_id}    ${vehicle_attribute}    ${vehicle_fragment}    ${content_type}
lopesg's avatar
lopesg committed
    Check Response Status Code  415    ${response['status']}

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

044_03_02_endpoint patch /subscriptions/{subscriptionId}
lopesg's avatar
lopesg committed
    [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})
lopesg's avatar
lopesg committed
    [Tags]  sub-update    6_3_4
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
    ${response}=  Update Subscription  ${id}     ${subscription_fragment}    ${content_type}
lopesg's avatar
lopesg committed
    Check Response Status Code  415    ${response['status']}

    [Teardown]  Delete Subscription  ${id}
lopesg's avatar
lopesg committed

044_03_03_endpoint post /entities/
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entities/)
lopesg's avatar
lopesg committed
    [Tags]  e-create    6_3_4
lopesg's avatar
lopesg committed

    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
lopesg's avatar
lopesg committed
    ${request}    ${response}=    Create Entity Selecting Content Type   ${building_filename}      ${entity_id}     ${content_type}
lopesg's avatar
lopesg committed
    Check Response Status Code  415    ${response['status']}

    [Teardown]    Delete Entity by Id       ${entity_id}

044_03_04_endpoint post /subscriptions/
lopesg's avatar
lopesg committed
    [Documentation]  Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /subscriptions/)
lopesg's avatar
lopesg committed
    [Tags]  sub-create    6_3_4
lopesg's avatar
lopesg committed

    ${subscriptions_id}=     Generate Random Entity Id    ${subscription_id_prefix}
lopesg's avatar
lopesg committed
    ${response}=  Create Subscription  ${subscriptions_id}    ${subscription_filename}    ${content_type}
lopesg's avatar
lopesg committed
    Check Response Status Code  415    ${response['status']}

    [Teardown]  Delete Subscription  ${subscriptions_id}

044_03_05_endpoint post /entityOperations/create
lopesg's avatar
lopesg committed
    [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)
lopesg's avatar
lopesg committed
    [Tags]  be-create    6_3_4
lopesg's avatar
lopesg committed

    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${second_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${first_entity}=    Load Entity    ${building_filename}      ${first_entity_id}
    ${second_entity}=    Load Entity    ${building_filename}      ${second_entity_id}
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}

lopesg's avatar
lopesg committed
    Batch Create Entities   @{entities_to_be_created}    content_type=${content_type}
lopesg's avatar
lopesg committed

    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  415

    [Teardown]  Batch Delete Entities  @{expected_entities_ids}

044_03_06_endpoint post /temporal/entities/
lopesg's avatar
lopesg committed
    [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/)
lopesg's avatar
lopesg committed
    [Tags]  te-create    6_3_4
lopesg's avatar
lopesg committed
    
lopesg's avatar
lopesg committed
    ${temporal_entity_representation_id}=     Generate Random Entity Id    ${tea_id_prefix}
lopesg's avatar
lopesg committed
    ${response}=  Create Or Update Temporal Representation Of Entity Selecting Content Type  ${temporal_entity_representation_id}    ${tea_filename}     ${content_type}
lopesg's avatar
lopesg committed
    Check Response Status Code  415    ${response['status']}

    [Teardown]    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}