当前位置: 首页>>代码示例>>Python>>正文


Python tests.op_fixture函数代码示例

本文整理汇总了Python中tests.op_fixture函数的典型用法代码示例。如果您正苦于以下问题:Python op_fixture函数的具体用法?Python op_fixture怎么用?Python op_fixture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了op_fixture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_alter_column_schema_schema_type_existing_type_no_const

def test_alter_column_schema_schema_type_existing_type_no_const():
    context = op_fixture('postgresql')
    op.alter_column("t", "c", type_=String(10), existing_type=Boolean(),
            schema='foo')
    context.assert_(
        'ALTER TABLE foo.t ALTER COLUMN c TYPE VARCHAR(10)'
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例2: test_alter_column_nullable_w_new_type

 def test_alter_column_nullable_w_new_type(self):
     context = op_fixture('oracle')
     op.alter_column("t", "c", nullable=True, type_=Integer)
     context.assert_(
         "ALTER TABLE t MODIFY c NULL",
         'ALTER TABLE t MODIFY c INTEGER'
     )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_oracle.py

示例3: test_rename_column_serv_default

def test_rename_column_serv_default():
    context = op_fixture('mysql')
    op.alter_column('t1', 'c1', new_column_name="c2", existing_type=Integer,
                        existing_server_default="q")
    context.assert_(
        "ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL DEFAULT 'q'"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_mysql.py

示例4: test_alter_column_schema_schema_type_existing_type_no_new_type

def test_alter_column_schema_schema_type_existing_type_no_new_type():
    context = op_fixture('postgresql')
    op.alter_column("t", "c", nullable=False, existing_type=Boolean(),
            schema='foo')
    context.assert_(
        'ALTER TABLE foo.t ALTER COLUMN c SET NOT NULL'
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例5: test_add_column_fk_self_referential

def test_add_column_fk_self_referential():
    context = op_fixture()
    op.add_column('t1', Column('c1', Integer, ForeignKey('t1.c2'), nullable=False))
    context.assert_(
        "ALTER TABLE t1 ADD COLUMN c1 INTEGER NOT NULL",
        "ALTER TABLE t1 ADD FOREIGN KEY(c1) REFERENCES t1 (c2)"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例6: test_add_column_fk_schema

def test_add_column_fk_schema():
    context = op_fixture()
    op.add_column('t1', Column('c1', Integer, ForeignKey('remote.t2.c2'), nullable=False))
    context.assert_(
    'ALTER TABLE t1 ADD COLUMN c1 INTEGER NOT NULL',
    'ALTER TABLE t1 ADD FOREIGN KEY(c1) REFERENCES remote.t2 (c2)'
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例7: test_drop_check

def test_drop_check():
    context = op_fixture('mysql')
    assert_raises_message(
        NotImplementedError,
        "MySQL does not support CHECK constraints.",
        op.drop_constraint, "f1", "t1", "check"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_mysql.py

示例8: test_alter_column_dont_touch_constraints

 def test_alter_column_dont_touch_constraints(self):
     context = op_fixture('mssql')
     from sqlalchemy import Boolean
     op.alter_column('tests', 'col',
         existing_type=Boolean(),
         nullable=False)
     context.assert_('ALTER TABLE tests ALTER COLUMN col BIT NOT NULL')
开发者ID:Lifto,项目名称:alembic,代码行数:7,代码来源:test_mssql.py

示例9: test_col_add_autoincrement

def test_col_add_autoincrement():
    context = op_fixture('mysql')
    op.alter_column('t1', 'c1', new_column_name="c2", existing_type=Integer,
                                autoincrement=True)
    context.assert_(
        'ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL AUTO_INCREMENT'
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_mysql.py

示例10: test_add_foreign_key_self_referential

def test_add_foreign_key_self_referential():
    context = op_fixture()
    op.create_foreign_key("fk_test", "t1", "t1", ["foo"], ["bar"])
    context.assert_(
        "ALTER TABLE t1 ADD CONSTRAINT fk_test "
        "FOREIGN KEY(foo) REFERENCES t1 (bar)"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例11: test_add_column_fk

def test_add_column_fk():
    context = op_fixture()
    op.add_column('t1', Column('c1', Integer, ForeignKey('c2.id'), nullable=False))
    context.assert_(
        "ALTER TABLE t1 ADD COLUMN c1 INTEGER NOT NULL",
        "ALTER TABLE t1 ADD FOREIGN KEY(c1) REFERENCES c2 (id)"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例12: test_create_index_table_col_event

def test_create_index_table_col_event():
    context = op_fixture()

    op.create_index('ik_test', 'tbl_with_auto_appended_column', ['foo', 'bar'])
    context.assert_(
        "CREATE INDEX ik_test ON tbl_with_auto_appended_column (foo, bar)"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例13: test_col_alter_type_required

def test_col_alter_type_required():
    context = op_fixture('mysql')
    assert_raises_message(
        util.CommandError,
        "All MySQL ALTER COLUMN operations require the existing type.",
        op.alter_column, 't1', 'c1', nullable=False, server_default="q"
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_mysql.py

示例14: test_alter_column_schema_type_existing_type

def test_alter_column_schema_type_existing_type():
    context = op_fixture('mssql')
    op.alter_column("t", "c", type_=String(10), existing_type=Boolean(name="xyz"))
    context.assert_(
        'ALTER TABLE t DROP CONSTRAINT xyz',
        'ALTER TABLE t ALTER COLUMN c VARCHAR(10)'
    )
开发者ID:shadowmint,项目名称:py-test-watcher,代码行数:7,代码来源:test_op.py

示例15: test_alter_replace_server_default

 def test_alter_replace_server_default(self):
     context = op_fixture('mssql')
     op.alter_column("t", "c", server_default="5", existing_server_default="6")
     context.assert_contains("exec('alter table t drop constraint ' + @const_name)")
     context.assert_contains(
         "ALTER TABLE t ADD DEFAULT '5' FOR c"
     )
开发者ID:Lifto,项目名称:alembic,代码行数:7,代码来源:test_mssql.py


注:本文中的tests.op_fixture函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。