MCPcopy Index your code
hub / github.com/PyMySQL/mysqlclient / check_data_integrity

Method check_data_integrity

tests/capabilities.py:82–104  ·  view source on GitHub ↗
(self, columndefs, generator)

Source from the content-addressed store, hash-verified

80 )
81
82 def check_data_integrity(self, columndefs, generator):
83 # insert
84 self.create_table(columndefs)
85 insert_statement = "INSERT INTO {} VALUES ({})".format(
86 self.table,
87 ",".join(["%s"] * len(columndefs)),
88 )
89 data = [
90 [generator(i, j) for j in range(len(columndefs))] for i in range(self.rows)
91 ]
92 self.cursor.executemany(insert_statement, data)
93 self.connection.commit()
94 # verify
95 self.cursor.execute("select * from %s" % self.table)
96 res = self.cursor.fetchall()
97 self.assertEqual(len(res), self.rows)
98 try:
99 for i in range(self.rows):
100 for j in range(len(columndefs)):
101 self.assertEqual(res[i][j], generator(i, j))
102 finally:
103 if not self.debug:
104 self.cursor.execute("drop table %s" % (self.table))
105
106 def test_transactions(self):
107 columndefs = ("col1 INT", "col2 VARCHAR(255)")

Callers 15

test_CHARMethod · 0.95
test_INTMethod · 0.95
test_DECIMALMethod · 0.95
test_DATEMethod · 0.95
test_TIMEMethod · 0.95
test_DATETIMEMethod · 0.95
test_TIMESTAMPMethod · 0.95
test_LONGMethod · 0.95
test_TEXTMethod · 0.95
test_LONG_BYTEMethod · 0.95
test_BLOBMethod · 0.95

Calls 4

create_tableMethod · 0.95
executemanyMethod · 0.80
executeMethod · 0.80
fetchallMethod · 0.45

Tested by 15

test_CHARMethod · 0.76
test_INTMethod · 0.76
test_DECIMALMethod · 0.76
test_DATEMethod · 0.76
test_TIMEMethod · 0.76
test_DATETIMEMethod · 0.76
test_TIMESTAMPMethod · 0.76
test_LONGMethod · 0.76
test_TEXTMethod · 0.76
test_LONG_BYTEMethod · 0.76
test_BLOBMethod · 0.76