Trees | Indices | Help |
---|
|
1 """ 2 This module implements the unit tests for 3 write of the atomic data types by VictorDatabase. 4 """ 5 6 import random 7 import unittest 8 import StringIO 9 import HTMLTestRunner 10 import traceback 11 import sys 12 13 from unittest_helper import * 14 from tuple_processor import * 15 from psql_util import * 16 import cStringIO 171918621 """ 22 Tests whether random data types are successfully written by VictorDatabase 23 @type schema: tuple 24 @param schema: represents the data types in the tuple 25 @type type_params: tuple 26 @param type_params: contains information(is_array_type, elm_size, random_fnc, elm_type, pack_fnc, convert_sql_fnc, 27 sql_create_type) about each data type in the tuple. 28 @type method_name: string 29 @param method_name: the name of the method who calls this generic method 30 """ 31 db_conn = psycopg2.connect('dbname={0}'.format(dbname)) 32 cur = db_conn.cursor() 33 34 for i in range(test_num): 35 create_table_query = create_table_from_fields(type_params) 36 cur.execute(create_table_query) 37 38 all_tuples = [] 39 for j in range(tuple_size): 40 rand_tuple = [] 41 42 for (is_array_type, elm_size, random_fnc, elm_type, pack_fnc, convert_sql_fnc, sql_create_type) in type_params: 43 # create rand data 44 data = create_rand_data(is_array_type, random_fnc) 45 46 # append to the tuple 47 rand_tuple.append(data) 48 49 all_tuples.append(rand_tuple) 50 51 db_conn.commit() 52 53 vdb = VictorDatabase(cur, schema, temp_table_name, 1) 54 vdb.write_tuples(all_tuples) 55 vdb.flush() 56 57 # not read the db and compare 58 cur.execute('SELECT * FROM ' + temp_table_name + ';') 59 ret_tuples = [] 60 for record in cur: 61 ret_tuples.append(record) 62 63 compare_set_of_tuples(self, type_params, all_tuples, ret_tuples, method_name, almost_equal)64 6567 """ 68 Tests whether tuples that only contain random char are successfully written by VictorDatabase 69 """ 70 self.generic_test_write_data([charoid], [char_vdb_type_param], 'write_single_char_type')71 7274 """ 75 Tests whether tuples that only contain random bool are successfully written by VictorDatabase 76 """ 77 self.generic_test_write_data([booloid], [bool_vdb_type_param], 'write_single_bool_type')78 7981 """ 82 Tests whether tuples that only contain random int2 are successfully written by VictorDatabase 83 """ 84 self.generic_test_write_data([int2oid], [int2_vdb_type_param], 'write_single_int2_type')85 8688 """ 89 Tests whether tuples that only contain random int4 are successfully written by VictorDatabase 90 """ 91 self.generic_test_write_data([int4oid], [int4_vdb_type_param], 'write_single_int4_type')92 9395 """ 96 Tests whether tuples that only contain random int8 are successfully written by VictorDatabase 97 """ 98 self.generic_test_write_data([int8oid], [int8_vdb_type_param], 'write_single_int8_type')99 100102 """ 103 Tests whether tuples that only contain random float4 are successfully written by VictorDatabase 104 """ 105 self.generic_test_write_data([float4oid], [float4_vdb_type_param], 'write_single_float4_type')106 107109 """ 110 Tests whether tuples that only contain random float8 are successfully written by VictorDatabase 111 """ 112 self.generic_test_write_data([float8oid], [float8_vdb_type_param], 'write_single_float8_type')113 114116 """ 117 Tests whether tuples that only contain random bool array are successfully written by VictorDatabase 118 """ 119 self.generic_test_write_data([boolarrayoid], [bool_array_vdb_type_param], 'write_single_bool_array_type')120 121123 """ 124 Tests whether tuples that only contain random int2 array are successfully written by VictorDatabase 125 """ 126 self.generic_test_write_data([int2arrayoid], [int2_array_vdb_type_param], 'write_single_int2_array_type')127 128130 """ 131 Tests whether tuples that only contain random int4 array are successfully written by VictorDatabase 132 """ 133 self.generic_test_write_data([int4arrayoid], [int4_array_vdb_type_param], 'write_single_int4_array_type')134 135137 """ 138 Tests whether tuples that only contain random int8 array are successfully written by VictorDatabase 139 """ 140 self.generic_test_write_data([int8arrayoid], [int8_array_vdb_type_param], 'write_single_int8_array_type')141 142144 """ 145 Tests whether tuples that only contain random float4 array are successfully written by VictorDatabase 146 """ 147 self.generic_test_write_data([float4arrayoid], [float4_array_vdb_type_param], 'write_single_float4_array_type')148 149151 """ 152 Tests whether tuples that only contain random float8 array are successfully written by VictorDatabase 153 """ 154 self.generic_test_write_data([float8arrayoid], [float8_array_vdb_type_param], 'write_single_float8_array_type')155 156158 """ 159 Tests whether tuples that only contain random float8 2d array are successfully written by VictorDatabase 160 """ 161 self.generic_test_write_data([float82darrayoid], [float8_2d_array_vdb_type_param], 'write_single_float8_2d_array_type')162 163165 """ 166 This method tests write of tuples with possible non-array data type combinations. 167 Since there are 7 non-array data types, all combinations produce 127 different schema. 168 """ 169 test_tuples_with_non_array_data(self.generic_test_write_data, limit_test, with_sql)170 171173 """ 174 This method tests write of tuples with possible array(1d or 2d) data type combinations. 175 Since there are 7 array data types, all combinations produce 127 different schema. 176 """ 177 test_tuples_with_array_data(self.generic_test_write_data, limit_test, with_sql)178 179181 """ 182 This method tests write of tuples with possible non-array and array(1d or 2d) data type combinations. 183 Since there are 14 data types, all combinations should produce 2 ** 14 - 1 different schema. 184 """ 185 test_tuples_with_data(self.generic_test_write_data, limit_test, with_sql)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Feb 28 00:56:45 2011 | http://epydoc.sourceforge.net |