|
21 | 21 | from cassandra.query import tuple_factory |
22 | 22 | from cassandra.cluster import Cluster |
23 | 23 | from tests.integration import use_singledc, PROTOCOL_VERSION, execute_until_pass |
24 | | -from tests.integration.datatype_utils import update_datatypes, PRIMITIVE_DATATYPES, get_sample |
| 24 | +from tests.integration.datatype_utils import update_datatypes, PRIMITIVE_DATATYPES |
| 25 | +from tests.integration.standard.utils import create_table_with_all_types, get_all_primitive_params |
25 | 26 | from six import binary_type |
26 | 27 |
|
27 | 28 | import uuid |
@@ -106,55 +107,18 @@ def test_custom_raw_row_results_all_types(self): |
106 | 107 | session.client_protocol_handler = CustomProtocolHandlerResultMessageTracked |
107 | 108 | session.row_factory = tuple_factory |
108 | 109 |
|
109 | | - columns_string = create_table_with_all_types("test_table", session) |
| 110 | + columns_string = create_table_with_all_types("alltypes", session) |
110 | 111 |
|
111 | 112 | # verify data |
112 | 113 | params = get_all_primitive_params() |
113 | | - results = session.execute("SELECT {0} FROM alltypes WHERE zz=0".format(columns_string))[0] |
| 114 | + results = session.execute("SELECT {0} FROM alltypes WHERE pimkey=0".format(columns_string))[0] |
114 | 115 | for expected, actual in zip(params, results): |
115 | 116 | self.assertEqual(actual, expected) |
116 | 117 | # Ensure we have covered the various primitive types |
117 | 118 | self.assertEqual(len(CustomResultMessageTracked.checked_rev_row_set), len(PRIMITIVE_DATATYPES)-1) |
118 | 119 | session.shutdown() |
119 | 120 |
|
120 | 121 |
|
121 | | -def create_table_with_all_types(table_name, session): |
122 | | - """ |
123 | | - Method that given a table_name and session construct a table that contains all possible primitive types |
124 | | - :param table_name: Name of table to create |
125 | | - :param session: session to use for table creation |
126 | | - :return: a string containing and columns. This can be used to query the table. |
127 | | - """ |
128 | | - # create table |
129 | | - alpha_type_list = ["zz int PRIMARY KEY"] |
130 | | - col_names = ["zz"] |
131 | | - start_index = ord('a') |
132 | | - for i, datatype in enumerate(PRIMITIVE_DATATYPES): |
133 | | - alpha_type_list.append("{0} {1}".format(chr(start_index + i), datatype)) |
134 | | - col_names.append(chr(start_index + i)) |
135 | | - |
136 | | - session.execute("CREATE TABLE alltypes ({0})".format(', '.join(alpha_type_list)), timeout=120) |
137 | | - |
138 | | - # create the input |
139 | | - params = get_all_primitive_params() |
140 | | - |
141 | | - # insert into table as a simple statement |
142 | | - columns_string = ', '.join(col_names) |
143 | | - placeholders = ', '.join(["%s"] * len(col_names)) |
144 | | - session.execute("INSERT INTO alltypes ({0}) VALUES ({1})".format(columns_string, placeholders), params, timeout=120) |
145 | | - return columns_string |
146 | | - |
147 | | - |
148 | | -def get_all_primitive_params(): |
149 | | - """ |
150 | | - Simple utility method used to give back a list of all possible primitive data sample types. |
151 | | - """ |
152 | | - params = [0] |
153 | | - for datatype in PRIMITIVE_DATATYPES: |
154 | | - params.append((get_sample(datatype))) |
155 | | - return params |
156 | | - |
157 | | - |
158 | 122 | class CustomResultMessageRaw(ResultMessage): |
159 | 123 | """ |
160 | 124 | This is a custom Result Message that is used to return raw results, rather then |
|
0 commit comments