Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit bc7a9dc

Browse files
sirupsenerezsh
authored andcommitted
tests: more cruel
1 parent f0f5ae2 commit bc7a9dc

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/test_database_types.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
"int": [127, -3, -9, 37, 15, 127],
1717
"datetime_no_timezone": [
1818
"2020-01-01 15:10:10",
19-
"2022-01-01 15:10:01.131",
19+
"2020-01-01 9:9:9",
20+
"999-1-1 9:9:9",
21+
"999-1-1 9:9:9.991",
22+
"2022-01-01 15:10:01.139",
2023
"2022-01-01 15:10:02.020409",
2124
"2022-01-01 15:10:03.003030",
22-
"2022-01-01 15:10:04.7",
2325
"2022-01-01 15:10:05.009900",
2426
],
2527
}
@@ -35,7 +37,7 @@
3537
# https://www.postgresql.org/docs/current/datatype-datetime.html
3638
"datetime_no_timezone": [
3739
"timestamp(6) without time zone",
38-
"timestamp without time zone",
40+
"timestamp(0) without time zone",
3941
]
4042
},
4143
db.MySQL: {
@@ -50,6 +52,7 @@
5052
# https://dev.mysql.com/doc/refman/8.0/en/datetime.html
5153
"datetime_no_timezone": [
5254
"timestamp(6)",
55+
"timestamp(0)",
5356
"timestamp",
5457
"datetime(6)"
5558
]
@@ -108,6 +111,7 @@ def test_wip_int_different(self, source_db, target_db, source_type, target_type,
108111
self.preql2, self.connection2 = CONNS[target_db][0], CONNS[target_db][1]
109112

110113
self.connections = [self.connection1, self.connection2]
114+
sample_values = TYPE_SAMPLES[type_category]
111115

112116
for i, connection in enumerate(self.connections):
113117
db_type = type(connection)
@@ -126,15 +130,15 @@ def test_wip_int_different(self, source_db, target_db, source_type, target_type,
126130

127131
connection.query("COMMIT", None)
128132

129-
for j, sample in enumerate(TYPE_SAMPLES[type_category]):
133+
for j, sample in enumerate(sample_values):
130134
connection.query(f"INSERT INTO {table} (id, col) VALUES ({j+1}, '{sample}')", None)
131135
connection.query("COMMIT", None)
132136

133137
self.table = TableSegment(self.connection1, ("a",), "id", None, ("col", ))
134138
self.table2 = TableSegment(self.connection2, ("b",), "id", None, ("col", ))
135139

136-
self.assertEqual(6, self.table.count())
137-
self.assertEqual(6, self.table2.count())
140+
self.assertEqual(len(sample_values), self.table.count())
141+
self.assertEqual(len(sample_values), self.table2.count())
138142

139143
differ = TableDiffer(bisection_threshold=3, bisection_factor=2) # ensure we actually checksum
140144
diff = list(differ.diff_tables(self.table, self.table2))
@@ -147,7 +151,7 @@ def test_wip_int_different(self, source_db, target_db, source_type, target_type,
147151
diff = list(differ.diff_tables(self.table, self.table2))
148152
expected = []
149153
self.assertEqual(expected, diff)
150-
self.assertEqual(6, differ.stats.get("rows_downloaded", 0))
154+
self.assertEqual(len(sample_values), differ.stats.get("rows_downloaded", 0))
151155

152156
duration = time.time() - start
153157
print(f"source_db={source_db.__name__} target_db={target_db.__name__} source_type={source_type} target_type={target_type} duration={round(duration * 1000, 2)}ms")

0 commit comments

Comments
 (0)