|
32 | 32 | from sqlalchemy.testing.assertions import ComparesTables
|
33 | 33 |
|
34 | 34 | import geoalchemy2
|
| 35 | +import geoalchemy2.dialects |
35 | 36 | from geoalchemy2 import Geography
|
36 | 37 | from geoalchemy2 import Geometry
|
37 | 38 | from geoalchemy2 import Raster
|
@@ -92,6 +93,39 @@ def test_no_geom_type(self, conn):
|
92 | 93 | # Drop the table
|
93 | 94 | t.drop(bind=conn)
|
94 | 95 |
|
| 96 | + @test_only_with_dialects("postgresql") |
| 97 | + def test_common_dialect(self, conn, monkeypatch, metadata, Lake): |
| 98 | + monkeypatch.setattr(conn.dialect, "name", "UNKNOWN DIALECT") |
| 99 | + |
| 100 | + marks = [] |
| 101 | + |
| 102 | + def before_create(table, bind, **kw): |
| 103 | + marks.append("before_create") |
| 104 | + return |
| 105 | + |
| 106 | + def after_create(table, bind, **kw): |
| 107 | + marks.append("after_create") |
| 108 | + return |
| 109 | + |
| 110 | + def before_drop(table, bind, **kw): |
| 111 | + marks.append("before_drop") |
| 112 | + return |
| 113 | + |
| 114 | + def after_drop(table, bind, **kw): |
| 115 | + marks.append("after_drop") |
| 116 | + return |
| 117 | + |
| 118 | + monkeypatch.setattr(geoalchemy2.dialects.common, "before_create", value=before_create) |
| 119 | + monkeypatch.setattr(geoalchemy2.dialects.common, "after_create", value=after_create) |
| 120 | + monkeypatch.setattr(geoalchemy2.dialects.common, "before_drop", value=before_drop) |
| 121 | + monkeypatch.setattr(geoalchemy2.dialects.common, "after_drop", value=after_drop) |
| 122 | + |
| 123 | + metadata.drop_all(conn, checkfirst=True) |
| 124 | + metadata.create_all(conn) |
| 125 | + metadata.drop_all(conn, checkfirst=True) |
| 126 | + |
| 127 | + assert marks == ["before_create", "after_create", "before_drop", "after_drop"] |
| 128 | + |
95 | 129 |
|
96 | 130 | class TestMiscellaneous:
|
97 | 131 | @test_only_with_dialects("sqlite")
|
|
0 commit comments