dddd3df8245c040d74d1f4015063c4dcdac4252c
[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}
17     ...    ${postfix}
18     ${node}=    Set Variable    car:cars/car-entry
19     Delete Records    ${controller_ip}    ${node}    ${0}    ${0}
20
21 Create Cars
22     [Arguments]    ${controller_ip}    ${first}    ${last}    ${field bases}
23     [Documentation]    Creates cars with record IDs of specified range using POST.
24     ...    If first and last are equal, only one record is updated.
25     ...    Field bases are a dictionary of datastore record field values onto which is appended
26     ...    an incremental value to uniquely identify the record from which it came.
27     ...    Typically, you will use the Create Dictionary keyword on an argument which looks like this:
28     ...    id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
29     ${node}=    Set Variable    car:cars
30     ${prefix}=    Set Variable    {"car-entry":[{
31     ${postfix}=    Set Variable    }]}
32     Create Records    ${controller_ip}    ${node}    ${first}    ${last}    ${prefix}    ${field bases}
33     ...    ${postfix}
34
35 Update Cars
36     [Arguments]    ${controller_ip}    ${first}    ${last}    ${field bases}
37     [Documentation]    Updates cars with record IDs of the specified using PUT.
38     ...    If first and last are equal, only one record is updated.
39     ...    Field bases are a dictionary of datastore record field values onto which is appended
40     ...    an incremental value to uniquely identify the record from which it came.
41     ...    Typically, you will use the Create Dictionary keyword on arguments which look like this:
42     ...    id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
43     ${node}=    Set Variable    car:cars/car-entry
44     ${prefix}=    Set Variable    {"car-entry":[{
45     ${postfix}=    Set Variable    }]}
46     Update Records    ${controller_ip}    ${node}    ${first}    ${last}    ${prefix}    ${field bases}
47     ...    ${postfix}
48
49 Read All Cars
50     [Arguments]    ${controller_ip}
51     [Documentation]    Returns all records from the cars shard in JSON format.
52     ${node}=    Set Variable    car:cars
53     ${result}=    Read Records    ${controller_ip}    ${node}
54     [Return]    ${result}
55
56 Read One Car
57     [Arguments]    ${controller_ip}    ${id}
58     [Documentation]    Returns the specified record from the cars shard in JSON format.
59     ${node}=    Set Variable    car:cars/car-entry/${id}
60     ${result}=    Read Records    ${controller_ip}    ${node}
61     [Return]    ${result}
62
63 Delete All Cars
64     [Arguments]    ${controller_ip}
65     [Documentation]    Deletes all records from the cars shard.
66     ${node}=    Set Variable    car:cars
67     Delete All Records    ${controller_ip}    ${node}
68
69 Delete Cars
70     [Arguments]    ${controller_ip}    ${first}    ${last}
71     [Documentation]    Deletes the specified range of records from the cars shard.
72     ${node}=    Set Variable    car:cars/car-entry
73     Delete Records    ${controller_ip}    ${node}    ${first}    ${last}