2323from sqlalchemy import Column , DateTime , Integer , String
2424
2525import google .api_core .exceptions
26+ from google .cloud .bigquery import SchemaField
2627
2728alembic = pytest .importorskip ("alembic" )
2829
@@ -43,10 +44,7 @@ def get_table(table_name, data="table"):
4344 if data == "table" :
4445 return table
4546 elif data == "schema" :
46- return [
47- repr (s ).replace (", (), None)" , ")" ).replace (", None)" , ")" )
48- for s in table .schema
49- ]
47+ return table .schema
5048 else :
5149 raise ValueError (data )
5250 except google .api_core .exceptions .NotFound :
@@ -78,9 +76,9 @@ def test_alembic_scenario(alembic_table):
7876 Column ("description" , String (200 )),
7977 )
8078 assert alembic_table ("account" , "schema" ) == [
81- " SchemaField('id', ' INTEGER', ' REQUIRED', None, (), ())" ,
82- " SchemaField(' name', ' STRING(50)', ' REQUIRED', ' The name', (), ())" ,
83- " SchemaField(' description', ' STRING(200)', 'NULLABLE', None, (), ())" ,
79+ SchemaField ("id" , " INTEGER" , " REQUIRED" ) ,
80+ SchemaField (" name" , " STRING(50)" , " REQUIRED" , description = " The name" ) ,
81+ SchemaField (" description" , " STRING(200)" ) ,
8482 ]
8583
8684 op .bulk_insert (
@@ -103,11 +101,10 @@ def test_alembic_scenario(alembic_table):
103101 )
104102
105103 assert alembic_table ("account" , "schema" ) == [
106- "SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())" ,
107- "SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())" ,
108- "SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())" ,
109- "SchemaField('last_transaction_date', 'DATETIME', 'NULLABLE', 'when updated'"
110- ", (), ())" ,
104+ SchemaField ("id" , "INTEGER" , "REQUIRED" ),
105+ SchemaField ("name" , "STRING(50)" , "REQUIRED" , description = "The name" ),
106+ SchemaField ("description" , "STRING(200)" ),
107+ SchemaField ("last_transaction_date" , "DATETIME" , description = "when updated" ),
111108 ]
112109
113110 op .create_table (
@@ -123,8 +120,8 @@ def test_alembic_scenario(alembic_table):
123120
124121 op .drop_column ("account_w_comment" , "description" )
125122 assert alembic_table ("account_w_comment" , "schema" ) == [
126- " SchemaField('id', ' INTEGER', ' REQUIRED', None, (), ())" ,
127- " SchemaField(' name', ' STRING(50)', ' REQUIRED', ' The name', (), ())" ,
123+ SchemaField ("id" , " INTEGER" , " REQUIRED" ) ,
124+ SchemaField (" name" , " STRING(50)" , " REQUIRED" , description = " The name" ) ,
128125 ]
129126
130127 op .drop_table ("account_w_comment" )
@@ -133,11 +130,10 @@ def test_alembic_scenario(alembic_table):
133130 op .rename_table ("account" , "accounts" )
134131 assert alembic_table ("account" ) is None
135132 assert alembic_table ("accounts" , "schema" ) == [
136- "SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())" ,
137- "SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())" ,
138- "SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())" ,
139- "SchemaField('last_transaction_date', 'DATETIME', 'NULLABLE', 'when updated'"
140- ", (), ())" ,
133+ SchemaField ("id" , "INTEGER" , "REQUIRED" ),
134+ SchemaField ("name" , "STRING(50)" , "REQUIRED" , description = "The name" ),
135+ SchemaField ("description" , "STRING(200)" ),
136+ SchemaField ("last_transaction_date" , "DATETIME" , description = "when updated" ),
141137 ]
142138 op .drop_table ("accounts" )
143139 assert alembic_table ("accounts" ) is None
@@ -157,9 +153,9 @@ def test_alembic_scenario(alembic_table):
157153 # nullable:
158154 op .alter_column ("transactions" , "amount" , True )
159155 assert alembic_table ("transactions" , "schema" ) == [
160- " SchemaField(' account', ' INTEGER', ' REQUIRED', None, (), ())" ,
161- " SchemaField(' transaction_time', ' DATETIME', ' REQUIRED', None, (), ())" ,
162- " SchemaField(' amount', ' NUMERIC(11, 2)', 'NULLABLE', None, (), ())" ,
156+ SchemaField (" account" , " INTEGER" , " REQUIRED" ) ,
157+ SchemaField (" transaction_time" , " DATETIME" , " REQUIRED" ) ,
158+ SchemaField (" amount" , " NUMERIC(11, 2)" ) ,
163159 ]
164160
165161 op .create_table_comment ("transactions" , "Transaction log" )
0 commit comments