|
| 1 | +*** Settings *** |
| 2 | +Suite Setup Connect To Database teradata ${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort} |
| 3 | +Suite Teardown Disconnect From Database |
| 4 | +Library DatabaseLibrary |
| 5 | +Library OperatingSystem |
| 6 | +Library Collections |
| 7 | + |
| 8 | +*** Variables *** |
| 9 | +${DBHost} 192.168.10.45 |
| 10 | +${DBName} ADRIAN |
| 11 | +${DBPass} dbc |
| 12 | +${DBPort} 1025 |
| 13 | +${DBUser} dbc |
| 14 | + |
| 15 | +*** Test Cases *** |
| 16 | +Create person table |
| 17 | + [Tags] db smoke |
| 18 | + ${output} = Execute SQL String CREATE TABLE person (id integer not null unique,first_name varchar(20),last_name varchar(20)); |
| 19 | + Log ${output} |
| 20 | + Should Be Equal As Strings ${output} None |
| 21 | + |
| 22 | +Execute SQL Script - Insert Data person table |
| 23 | + Comment ${output} = Execute SQL Script ./${DBName}_insertData.sql |
| 24 | + ${output} = Execute SQL Script ./my_db_test_insertData.sql |
| 25 | + Log ${output} |
| 26 | + Should Be Equal As Strings ${output} None |
| 27 | + |
| 28 | +Create foobar table |
| 29 | + ${output} = Execute SQL String create table foobar (id integer not null primary key, firstname varchar(100) not null unique) |
| 30 | + Log ${output} |
| 31 | + Should Be Equal As Strings ${output} None |
| 32 | + |
| 33 | +Check If Exists In DB - Franz Allan |
| 34 | + Check If Exists In Database SELECT id FROM person WHERE first_name = 'Franz Allan'; |
| 35 | + |
| 36 | +Check If Not Exists In DB - Joe |
| 37 | + Check If Not Exists In Database SELECT id FROM person WHERE first_name = 'Joe'; |
| 38 | + |
| 39 | +Table Must Exist - person |
| 40 | + Table Must Exist person |
| 41 | + |
| 42 | +Verify Row Count is 0 |
| 43 | + Row Count is 0 SELECT * FROM person WHERE first_name = 'NotHere'; |
| 44 | + |
| 45 | +Verify Row Count is Equal to X |
| 46 | + Row Count is Equal to X SELECT id FROM person; 2 |
| 47 | + |
| 48 | +Verify Row Count is Less Than X |
| 49 | + Row Count is Less Than X SELECT id FROM person; 3 |
| 50 | + |
| 51 | +Verify Row Count is Greater Than X |
| 52 | + Row Count is Greater Than X SELECT * FROM person; 1 |
| 53 | + |
| 54 | +Retrieve Row Count |
| 55 | + ${output} = Row Count SELECT id FROM person; |
| 56 | + Log ${output} |
| 57 | + Should Be Equal As Strings ${output} 2 |
| 58 | + |
| 59 | +Retrieve records from person table |
| 60 | + ${output} = Execute SQL String SELECT * FROM person; |
| 61 | + Log ${output} |
| 62 | + Should Be Equal As Strings ${output} None |
| 63 | + |
| 64 | +Verify person Description |
| 65 | + [Tags] db smoke |
| 66 | + Comment Query db for table column descriptions |
| 67 | + @{queryResults} = Description SELECT * FROM person SAMPLE 1; |
| 68 | + Log Many @{queryResults} |
| 69 | + ${output} = Set Variable ${queryResults[0]} |
| 70 | + Should Be Equal As Strings ${output} ('id', <class 'decimal.Decimal'>, None, 10, 0, None, 0) |
| 71 | + ${output} = Set Variable ${queryResults[1]} |
| 72 | + Should Be Equal As Strings ${output} ('first_name', <class 'str'>, None, 20, 0, None, 1) |
| 73 | + ${output} = Set Variable ${queryResults[2]} |
| 74 | + Should Be Equal As Strings ${output} ('last_name', <class 'str'>, None, 20, 0, None, 1) |
| 75 | + ${NumColumns} = Get Length ${queryResults} |
| 76 | + Should Be Equal As Integers ${NumColumns} 3 |
| 77 | + |
| 78 | +Verify foobar Description |
| 79 | + [Tags] db smoke |
| 80 | + Comment Query db for table column descriptions |
| 81 | + @{queryResults} = Description SELECT * FROM foobar SAMPLE 1; |
| 82 | + Log Many @{queryResults} |
| 83 | + ${output} = Set Variable ${queryResults[0]} |
| 84 | + Should Be Equal As Strings ${output} ('id', <class 'decimal.Decimal'>, None, 10, 0, None, 0) |
| 85 | + ${output} = Set Variable ${queryResults[1]} |
| 86 | + Should Be Equal As Strings ${output} ('firstname', <class 'str'>, None, 100, 0, None, 0) |
| 87 | + ${NumColumns} = Get Length ${queryResults} |
| 88 | + Should Be Equal As Integers ${NumColumns} 2 |
| 89 | + |
| 90 | +Verify Query - Row Count person table |
| 91 | + ${output} = Query SELECT COUNT(*) FROM person; |
| 92 | + Log ${output} |
| 93 | + ${val}= Get from list ${output} 0 |
| 94 | + ${val}= Convert to list ${val} |
| 95 | + ${val}= Get from list ${val} 0 |
| 96 | + Should be equal as Integers ${val} 2 |
| 97 | + |
| 98 | +Verify Query - Row Count foobar table |
| 99 | + ${output} = Query SELECT COUNT(*) FROM foobar; |
| 100 | + Log ${output} |
| 101 | + ${val}= Get from list ${output} 0 |
| 102 | + ${val}= Convert to list ${val} |
| 103 | + ${val}= Get from list ${val} 0 |
| 104 | + Should be equal as Integers ${val} 0 |
| 105 | + |
| 106 | +Verify Query - Get results as a list of dictionaries |
| 107 | + [Tags] db smoke |
| 108 | + ${output} = Query SELECT * FROM person; \ True |
| 109 | + Log ${output} |
| 110 | + Should Be Equal As Strings &{output[0]}[first_name] Franz Allan |
| 111 | + Should Be Equal As Strings &{output[1]}[first_name] Jerry |
| 112 | + |
| 113 | +Verify Execute SQL String - Row Count person table |
| 114 | + ${output} = Execute SQL String SELECT COUNT(*) FROM person; |
| 115 | + Log ${output} |
| 116 | + Should Be Equal As Strings ${output} None |
| 117 | + |
| 118 | +Verify Execute SQL String - Row Count foobar table |
| 119 | + ${output} = Execute SQL String SELECT COUNT(*) FROM foobar; |
| 120 | + Log ${output} |
| 121 | + Should Be Equal As Strings ${output} None |
| 122 | + |
| 123 | +Insert Data Into Table foobar |
| 124 | + ${output} = Execute SQL String INSERT INTO foobar VALUES(1,'Jerry'); |
| 125 | + Log ${output} |
| 126 | + Should Be Equal As Strings ${output} None |
| 127 | + |
| 128 | +Verify Query - Row Count foobar table 1 row |
| 129 | + ${output} = Query SELECT COUNT(*) FROM foobar; |
| 130 | + Log ${output} |
| 131 | + ${val}= Get from list ${output} 0 |
| 132 | + ${val}= Convert to list ${val} |
| 133 | + ${val}= Get from list ${val} 0 |
| 134 | + Should be equal as Integers ${val} 1 |
| 135 | + |
| 136 | +Verify Delete All Rows From Table - foobar |
| 137 | + Delete All Rows From Table foobar |
| 138 | + Comment Sleep 2s |
| 139 | + |
| 140 | +Verify Query - Row Count foobar table 0 row |
| 141 | + Row Count Is 0 SELECT * FROM foobar; |
| 142 | + Comment ${output} = Query SELECT COUNT(*) FROM foobar; |
| 143 | + Comment Log ${output} |
| 144 | + Comment Should Be Equal As Strings ${output} [(0,)] |
| 145 | + |
| 146 | +Drop person table |
| 147 | + ${output} = Execute SQL String DROP TABLE person; |
| 148 | + Log ${output} |
| 149 | + Should Be Equal As Strings ${output} None |
| 150 | + |
| 151 | +Drop foobar table |
| 152 | + ${output} = Execute SQL String DROP TABLE foobar; |
| 153 | + Log ${output} |
| 154 | + Should Be Equal As Strings ${output} None |
0 commit comments