| 21 | |
| 22 | |
| 23 | class EmitDDLTest(fixtures.TestBase): |
| 24 | def _mock_connection(self, item_exists): |
| 25 | def has_item(connection, name, schema): |
| 26 | return item_exists(name) |
| 27 | |
| 28 | def has_index(connection, tablename, idxname, schema): |
| 29 | return item_exists(idxname) |
| 30 | |
| 31 | return Mock( |
| 32 | dialect=Mock( |
| 33 | supports_sequences=True, |
| 34 | has_table=Mock(side_effect=has_item), |
| 35 | has_sequence=Mock(side_effect=has_item), |
| 36 | has_index=Mock(side_effect=has_index), |
| 37 | supports_comments=True, |
| 38 | inline_comments=False, |
| 39 | ), |
| 40 | _schema_translate_map=None, |
| 41 | ) |
| 42 | |
| 43 | def _mock_create_fixture( |
| 44 | self, checkfirst, tables, item_exists=lambda item: False |
| 45 | ): |
| 46 | connection = self._mock_connection(item_exists) |
| 47 | |
| 48 | return SchemaGenerator( |
| 49 | connection.dialect, |
| 50 | connection, |
| 51 | checkfirst=checkfirst, |
| 52 | tables=tables, |
| 53 | ) |
| 54 | |
| 55 | def _mock_drop_fixture( |
| 56 | self, checkfirst, tables, item_exists=lambda item: True |
| 57 | ): |
| 58 | connection = self._mock_connection(item_exists) |
| 59 | |
| 60 | return SchemaDropper( |
| 61 | connection.dialect, |
| 62 | connection, |
| 63 | checkfirst=checkfirst, |
| 64 | tables=tables, |
| 65 | ) |
| 66 | |
| 67 | def _table_fixture(self): |
| 68 | m = MetaData() |
| 69 | |
| 70 | return (m,) + tuple( |
| 71 | Table("t%d" % i, m, Column("x", Integer)) for i in range(1, 6) |
| 72 | ) |
| 73 | |
| 74 | def _table_and_view_fixture(self): |
| 75 | m = MetaData() |
| 76 | |
| 77 | tables = [ |
| 78 | Table("t%d" % i, m, Column("x", Integer)) for i in range(1, 4) |
| 79 | ] |
| 80 |
nothing calls this directly
no test coverage detected