Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_step_one_no_diff_in_migration(app):
db = Database(app, auto_migrate=False)
db.define_models(StepOneThing)
ops = _make_ops(db)
ops2 = _make_ops(db, ops)
assert len(ops2.as_diffs()) == 0
def test_step_three_drop_column(app):
db = Database(app, auto_migrate=False)
db.define_models(StepThreeThingTwo)
ops = _make_ops(db)
db2 = Database(app, auto_migrate=False)
db2.define_models(StepThreeThingThree)
ops2 = _make_ops(db2, ops)
op = ops2.ops[0]
sql = _make_sql(db, op)
assert sql == _step_three_sql_drop
def test_step_one_drop_table(app):
db = Database(app, auto_migrate=False)
db.define_models(StepOneThing)
ops = _make_ops(db)
db2 = Database(app, auto_migrate=False)
db2.define_models()
ops2 = _make_ops(db2, ops)
diffs = ops2.as_diffs()
assert len(diffs) == 1 and diffs[0][0] == "remove_table"
op = ops2.ops[0]
sql = _make_sql(db2, op)
assert sql == _step_one_sql_drop
def test_step_three_create_column(app):
db = Database(app, auto_migrate=False)
db.define_models(StepThreeThingOne)
ops = _make_ops(db)
db2 = Database(app, auto_migrate=False)
db2.define_models(StepThreeThingTwo)
ops2 = _make_ops(db2, ops)
op = ops2.ops[0]
sql = _make_sql(db, op)
assert sql == _step_three_sql
def test_step_one_create_table(app):
db = Database(app, auto_migrate=False)
db.define_models(StepOneThing)
ops = _make_ops(db)
diffs = ops.as_diffs()
assert len(diffs) == 1 and diffs[0][0] == "add_table"
op = ops.ops[0]
sql = _make_sql(db, op)
assert sql == _step_one_sql
def test_step_five_indexes(app):
db = Database(app, auto_migrate=False)
db.define_models(StepFiveThing)
ops = _make_ops(db)
index_ops = ops.ops[1:]
for op in index_ops:
sql = _make_sql(db, op)
assert sql in _step_five_sql_before
db2 = Database(app, auto_migrate=False)
db2.define_models(StepFiveThingEdit)
ops2 = _make_ops(db2, ops)
for op in ops2.ops:
sql = _make_sql(db, op)
assert sql in _step_five_sql_after
def test_step_five_indexes(app):
db = Database(app, auto_migrate=False)
db.define_models(StepFiveThing)
ops = _make_ops(db)
index_ops = ops.ops[1:]
for op in index_ops:
sql = _make_sql(db, op)
assert sql in _step_five_sql_before
db2 = Database(app, auto_migrate=False)
db2.define_models(StepFiveThingEdit)
ops2 = _make_ops(db2, ops)
for op in ops2.ops:
sql = _make_sql(db, op)
assert sql in _step_five_sql_after
def test_step_three_drop_column(app):
db = Database(app, auto_migrate=False)
db.define_models(StepThreeThingTwo)
ops = _make_ops(db)
db2 = Database(app, auto_migrate=False)
db2.define_models(StepThreeThingThree)
ops2 = _make_ops(db2, ops)
op = ops2.ops[0]
sql = _make_sql(db, op)
assert sql == _step_three_sql_drop
def test_step_two_create_table(app):
db = Database(app, auto_migrate=False)
db.define_models(StepTwoThing)
ops = _make_ops(db)
op = ops.ops[0]
sql = _make_sql(db, op)
assert sql == _step_two_sql
def db():
app = App(__name__)
db = Database(
app, config=sdict(
uri='sqlite:memory', auto_migrate=True, auto_connect=True))
db.define_models(Register)
return db