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