20
20
# software solely pursuant to the terms of the relevant commercial agreement.
21
21
22
22
import sqlalchemy as sa
23
-
24
23
try :
25
24
from sqlalchemy .orm import declarative_base
26
25
except ImportError :
32
31
from unittest import TestCase
33
32
from unittest .mock import patch , MagicMock
34
33
34
+
35
35
fake_cursor = MagicMock (name = 'fake_cursor' )
36
36
FakeCursor = MagicMock (name = 'FakeCursor' , spec = Cursor )
37
37
FakeCursor .return_value = fake_cursor
@@ -77,7 +77,6 @@ class DummyTable(self.Base):
77
77
__tablename__ = 'dummy'
78
78
pk = sa .Column (sa .String , primary_key = True )
79
79
obj_col = sa .Column (Object )
80
-
81
80
self .Base .metadata .create_all (bind = self .engine )
82
81
fake_cursor .execute .assert_called_with (
83
82
('\n CREATE TABLE dummy (\n \t pk STRING NOT NULL, \n \t obj_col OBJECT, '
@@ -92,7 +91,6 @@ class DummyTable(self.Base):
92
91
}
93
92
pk = sa .Column (sa .String , primary_key = True )
94
93
p = sa .Column (sa .String )
95
-
96
94
self .Base .metadata .create_all (bind = self .engine )
97
95
fake_cursor .execute .assert_called_with (
98
96
('\n CREATE TABLE t (\n \t '
@@ -107,7 +105,6 @@ class DummyTable(self.Base):
107
105
__tablename__ = 't'
108
106
ts = sa .Column (sa .BigInteger , primary_key = True )
109
107
p = sa .Column (sa .BigInteger , sa .Computed ("date_trunc('day', ts)" ))
110
-
111
108
self .Base .metadata .create_all (bind = self .engine )
112
109
fake_cursor .execute .assert_called_with (
113
110
('\n CREATE TABLE t (\n \t '
@@ -122,7 +119,6 @@ class DummyTable(self.Base):
122
119
__tablename__ = 't'
123
120
ts = sa .Column (sa .BigInteger , primary_key = True )
124
121
p = sa .Column (sa .BigInteger , sa .Computed ("date_trunc('day', ts)" , persisted = False ))
125
-
126
122
with self .assertRaises (sa .exc .CompileError ):
127
123
self .Base .metadata .create_all (bind = self .engine )
128
124
@@ -135,7 +131,6 @@ class DummyTable(self.Base):
135
131
}
136
132
pk = sa .Column (sa .String , primary_key = True )
137
133
p = sa .Column (sa .String )
138
-
139
134
self .Base .metadata .create_all (bind = self .engine )
140
135
fake_cursor .execute .assert_called_with (
141
136
('\n CREATE TABLE t (\n \t '
@@ -171,7 +166,6 @@ class DummyTable(self.Base):
171
166
}
172
167
pk = sa .Column (sa .String , primary_key = True )
173
168
p = sa .Column (sa .String , primary_key = True )
174
-
175
169
self .Base .metadata .create_all (bind = self .engine )
176
170
fake_cursor .execute .assert_called_with (
177
171
('\n CREATE TABLE t (\n \t '
@@ -213,7 +207,6 @@ def test_column_pk_nullable(self):
213
207
class DummyTable (self .Base ):
214
208
__tablename__ = 't'
215
209
pk = sa .Column (sa .String , primary_key = True , nullable = True )
216
-
217
210
with self .assertRaises (sa .exc .CompileError ):
218
211
self .Base .metadata .create_all (bind = self .engine )
219
212
@@ -237,7 +230,6 @@ class DummyTable(self.Base):
237
230
__tablename__ = 't'
238
231
pk = sa .Column (sa .String , primary_key = True )
239
232
a = sa .Column (Geopoint , crate_index = False )
240
-
241
233
with self .assertRaises (sa .exc .CompileError ):
242
234
self .Base .metadata .create_all (bind = self .engine )
243
235
0 commit comments