Support OVSDB entity ownership ID format
[integration/test.git] / csit / libraries / IoTDM / iotdm_sanity_tests.robot
1 *** Settings ***
2 Documentation     Keywords for sanity test suites testing basic functionality
3 ...               using multiple communication protocols
4 Library           Collections
5 Resource          ../../variables/Variables.robot
6 Resource          IoTDMKeywords.robot
7 Resource          IoTDMResources.robot
8 Library           iotdm_comm.py
9 Library           OperatingSystem
10 Variables         client_libs/onem2m_primitive.py
11
12 *** Keywords ***
13 Sanity Test Create AE
14     [Documentation]    Create AE resource and verify response
15     Create Resource AE
16
17 Sanity Test Retrieve AE
18     [Documentation]    Retrieve AE resource and verify response
19     Retrieve Resource    ${defAeUri}
20
21 Sanity Test Update AE
22     [Documentation]    Update AE resource and verify response
23     ${attr} =    Set Variable    {"m2m:ae": {"or":"http://hey/you/updated"}}
24     Update Resource    ${attr}    ${defAeUri}
25
26 Sanity Test Retrieve Updated AE
27     [Documentation]    Retrieve updated AE, verify updated element and verify response
28     ${rsp_primitive}    Retrieve Resource    ${defAeUri}
29     ${update_or} =    Get Primitive Content Attribute    ${rsp_primitive}    /m2m:ae/or
30     Should Be Equal    ${update_or}    http://hey/you/updated
31
32 Sanity Test Delete AE
33     [Documentation]    Delete AE resource and verify response
34     Delete Resource    ${defAeUri}
35
36 Sanity Test Retrieve Deleted AE
37     [Documentation]    Try to retrieve already deleted AE. Expect and verify error response
38     ${primitive} =    New Retrieve Request Primitive    ${defAeUri}
39     Log Primitive    ${primitive}
40     ${rsp_primitive} =    Send Primitive    ${primitive}
41     Log Primitive    ${rsp_primitive}
42     ${expected_message} =    Set Variable    Resource target URI not found: ${defAeUri}
43     Verify Exchange Negative    ${primitive}    ${rsp_primitive}    ${OneM2M.result_code_not_found}    ${expected_message}
44
45 Sanity Test Create AE Container Subscription
46     [Arguments]    ${notification_uri}
47     [Documentation]    Create AE, Container and Subscription resources. Subscription resource has set
48     ...    eventType 3 so notification will be trigerred when child resource of Container resource is
49     ...    created. Notifications will be sent to communication Rx channel.
50     ...    Verify response of create requests.
51     Sanity Test Create AE
52     Create Resource Container    ${defAeUri}    Container1
53     Create Resource Subscription    ${defAeUri}/Container1    ${notification_uri}    notifEventType=${OneM2M.net_create_of_direct_child_resource}    notifContentType=${OneM2M.nct_resource_id}
54
55 Sanity Test Create Content Instance And Handle Notification
56     [Documentation]    Create contentInstance resource what should trigger notification. Receive the notification
57     ...    and create positive response and send. Verify the received notification request.
58     Create Content Instance
59     ${notification} =    Receive Notification And Verify
60     # response must be sent becaue Rx is waiting for the response and Rx thread is blocked
61     ${notification_rsp} =    Create Notification Response    ${notification}
62     Respond Response Primitive    ${notification_rsp}
63     Verify Exchange    ${notification}    ${notification_rsp}
64
65 Sanity Test Create Content Instance And Use Automatic Notification Response
66     [Documentation]    Set up automatic reply for notifications from specific subscription resource. Create
67     ...    contentInstance resource what will trigger the notification and check if was handled
68     ...    automatically.
69     ${subscription_resource_id}    Set Variable    ${defAeUri}/Container1/${defSubscriptionName}
70     Add Auto Reply To Notification From Subscription    ${subscription_resource_id}
71     Create Content Instance
72     Wait Until Keyword Succeeds    3x    100ms    Verify Number Of Auto Replies To Notification From Subscription    ${subscription_resource_id}    ${1}
73     Remove Auto Reply To Notification From Subscription    ${subscription_resource_id}
74
75 Create Content Instance
76     Create Resource ContentInstance    contentValue=testingContentValue    parentResourceUri=${defAeUri}/Container1
77
78 Receive Notification And Verify
79     ${notification} =    Receive Request Primitive
80     Verify Request    ${notification}
81     ${from} =    Get Primitive Param    ${notification}    ${OneM2M.short_from}
82     Should Be Equal    ${from}    /${defCseBaseName}
83     ${operation} =    Get Primitive Param    ${notification}    ${OneM2M.short_operation}
84     Should Be Equal As Integers    ${operation}    ${OneM2M.operation_notify}
85     Return From Keyword    ${notification}