fix test error
This commit is contained in:
parent
01fa7fbbdb
commit
86e1d3defb
@ -7,6 +7,7 @@ ChangeLog
|
|||||||
0.2.1
|
0.2.1
|
||||||
-----
|
-----
|
||||||
- Fix bug in windows.
|
- Fix bug in windows.
|
||||||
|
- Enhance PostgreSQL support.
|
||||||
|
|
||||||
0.2.0
|
0.2.0
|
||||||
-----
|
-----
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from typing import Type
|
||||||
|
|
||||||
|
from tortoise import Model
|
||||||
from tortoise.backends.asyncpg.schema_generator import AsyncpgSchemaGenerator
|
from tortoise.backends.asyncpg.schema_generator import AsyncpgSchemaGenerator
|
||||||
from tortoise.fields import Field
|
from tortoise.fields import Field
|
||||||
|
|
||||||
|
@ -73,7 +73,10 @@ def test_modify_column():
|
|||||||
|
|
||||||
ret = Migrate.ddl.modify_column(User, User._meta.fields_map.get("is_active"))
|
ret = Migrate.ddl.modify_column(User, User._meta.fields_map.get("is_active"))
|
||||||
if isinstance(Migrate.ddl, MysqlDDL):
|
if isinstance(Migrate.ddl, MysqlDDL):
|
||||||
assert ret == "ALTER TABLE `user` MODIFY COLUMN `is_active` BOOL NOT NULL"
|
assert (
|
||||||
|
ret
|
||||||
|
== "ALTER TABLE `user` MODIFY COLUMN `is_active` BOOL NOT NULL COMMENT 'Is Active' DEFAULT 1"
|
||||||
|
)
|
||||||
elif isinstance(Migrate.ddl, PostgresDDL):
|
elif isinstance(Migrate.ddl, PostgresDDL):
|
||||||
assert ret == 'ALTER TABLE "user" ALTER COLUMN "is_active" TYPE BOOL'
|
assert ret == 'ALTER TABLE "user" ALTER COLUMN "is_active" TYPE BOOL'
|
||||||
else:
|
else:
|
||||||
@ -88,7 +91,7 @@ def test_alter_column_default():
|
|||||||
if isinstance(Migrate.ddl, PostgresDDL):
|
if isinstance(Migrate.ddl, PostgresDDL):
|
||||||
assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" DROP DEFAULT'
|
assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" DROP DEFAULT'
|
||||||
else:
|
else:
|
||||||
assert ret == None
|
assert ret is None
|
||||||
|
|
||||||
ret = Migrate.ddl.alter_column_default(Category, Category._meta.fields_map.get("created_at"))
|
ret = Migrate.ddl.alter_column_default(Category, Category._meta.fields_map.get("created_at"))
|
||||||
if isinstance(Migrate.ddl, PostgresDDL):
|
if isinstance(Migrate.ddl, PostgresDDL):
|
||||||
@ -96,13 +99,13 @@ def test_alter_column_default():
|
|||||||
ret == 'ALTER TABLE "category" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP'
|
ret == 'ALTER TABLE "category" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
assert ret == None
|
assert ret is None
|
||||||
|
|
||||||
ret = Migrate.ddl.alter_column_default(User, User._meta.fields_map.get("avatar"))
|
ret = Migrate.ddl.alter_column_default(User, User._meta.fields_map.get("avatar"))
|
||||||
if isinstance(Migrate.ddl, PostgresDDL):
|
if isinstance(Migrate.ddl, PostgresDDL):
|
||||||
assert ret == 'ALTER TABLE "user" ALTER COLUMN "avatar" SET DEFAULT \'\''
|
assert ret == 'ALTER TABLE "user" ALTER COLUMN "avatar" SET DEFAULT \'\''
|
||||||
else:
|
else:
|
||||||
assert ret == None
|
assert ret is None
|
||||||
|
|
||||||
|
|
||||||
def test_alter_column_null():
|
def test_alter_column_null():
|
||||||
@ -110,7 +113,7 @@ def test_alter_column_null():
|
|||||||
if isinstance(Migrate.ddl, PostgresDDL):
|
if isinstance(Migrate.ddl, PostgresDDL):
|
||||||
assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" SET NOT NULL'
|
assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" SET NOT NULL'
|
||||||
else:
|
else:
|
||||||
assert ret == None
|
assert ret is None
|
||||||
|
|
||||||
|
|
||||||
def test_set_comment():
|
def test_set_comment():
|
||||||
@ -118,13 +121,13 @@ def test_set_comment():
|
|||||||
if isinstance(Migrate.ddl, PostgresDDL):
|
if isinstance(Migrate.ddl, PostgresDDL):
|
||||||
assert ret == 'COMMENT ON COLUMN "category"."name" IS NULL'
|
assert ret == 'COMMENT ON COLUMN "category"."name" IS NULL'
|
||||||
else:
|
else:
|
||||||
assert ret == None
|
assert ret is None
|
||||||
|
|
||||||
ret = Migrate.ddl.set_comment(Category, Category._meta.fields_map.get("user"))
|
ret = Migrate.ddl.set_comment(Category, Category._meta.fields_map.get("user"))
|
||||||
if isinstance(Migrate.ddl, PostgresDDL):
|
if isinstance(Migrate.ddl, PostgresDDL):
|
||||||
assert ret == 'COMMENT ON COLUMN "category"."user" IS \'User\''
|
assert ret == 'COMMENT ON COLUMN "category"."user" IS \'User\''
|
||||||
else:
|
else:
|
||||||
assert ret == None
|
assert ret is None
|
||||||
|
|
||||||
|
|
||||||
def test_drop_column():
|
def test_drop_column():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user