Step 1: Move vm scripts to the right place
[integration/test.git] / csit / libraries / CarsAndPeopleCRUD.robot
1 *** Settings ***
2 Library           Collections
3 Resource          DatastoreCRUD.robot
4
5 *** Keywords ***
6 Initialize Cars
7     [Arguments]    ${controller_ip}    ${field bases}
8     [Documentation]    Initializes the cars shard by creating a 0th car with POST then deleting it.
9     ...    Field bases are a dictionary of datastore record field values onto which is appended
10     ...    an incremental value to uniquely identify the record from which it came.
11     ...    Typically, you will use the Create Dictionary keyword on arguments which look like this:
12     ...    id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
13     ${node}=    Set Variable    ${EMPTY}
14     ${prefix}=    Set Variable    {"car:cars":{"car-entry":[{
15     ${postfix}=    Set Variable    }]}}
16     Create Records    ${controller_ip}    ${node}    ${0}    ${0}    ${prefix}    ${field bases}    ${postfix}
17     ${node}=    Set Variable    car:cars/car-entry
18     Delete Records    ${controller_ip}    ${node}    ${0}    ${0}
19
20 Create Cars
21     [Arguments]    ${controller_ip}    ${first}    ${last}    ${field bases}
22     [Documentation]    Creates cars with record IDs of specified range using POST.
23     ...    If first and last are equal, only one record is updated.
24     ...    Field bases are a dictionary of datastore record field values onto which is appended
25     ...    an incremental value to uniquely identify the record from which it came.
26     ...    Typically, you will use the Create Dictionary keyword on an argument which looks like this:
27     ...    id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
28     ${node}=    Set Variable    car:cars
29     ${prefix}=    Set Variable    {"car-entry":[{
30     ${postfix}=    Set Variable    }]}
31     Create Records    ${controller_ip}    ${node}    ${first}    ${last}    ${prefix}    ${field bases}    ${postfix}
32
33 Update Cars
34     [Arguments]    ${controller_ip}    ${first}    ${last}    ${field bases}
35     [Documentation]    Updates cars with record IDs of the specified using PUT.
36     ...    If first and last are equal, only one record is updated.
37     ...    Field bases are a dictionary of datastore record field values onto which is appended
38     ...    an incremental value to uniquely identify the record from which it came.
39     ...    Typically, you will use the Create Dictionary keyword on arguments which look like this:
40     ...    id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
41     ${node}=    Set Variable    car:cars/car-entry
42     ${prefix}=    Set Variable    {"car-entry":[{
43     ${postfix}=    Set Variable    }]}
44     Update Records    ${controller_ip}    ${node}    ${first}    ${last}    ${prefix}    ${field bases}    ${postfix}
45
46 Read All Cars
47     [Arguments]    ${controller_ip}
48     [Documentation]    Returns all records from the cars shard in JSON format.
49     ${node}=    Set Variable    car:cars
50     ${result}=    Read Records    ${controller_ip}    ${node}
51     [Return]    ${result}
52
53 Read One Car
54     [Arguments]    ${controller_ip}    ${id}
55     [Documentation]    Returns the specified record from the cars shard in JSON format.
56     ${node}=    Set Variable    car:cars/car-entry/${id}
57     ${result}=    Read Records    ${controller_ip}    ${node}
58     [Return]    ${result}
59
60 Delete All Cars
61     [Arguments]    ${controller_ip}
62     [Documentation]    Deletes all records from the cars shard.
63     ${node}=    Set Variable    car:cars
64     Delete All Records    ${controller_ip}    ${node}
65
66 Delete Cars
67     [Arguments]    ${controller_ip}    ${first}    ${last}
68     [Documentation]    Deletes the specified range of records from the cars shard.
69     ${node}=    Set Variable    car:cars/car-entry
70     Delete Records    ${controller_ip}    ${node}    ${first}    ${last}