def test_with_range(self): out = six.StringIO() cmd = Downgrade(stdout=out) with self.assertRaises(SystemExit): cmd.run_from_argv([ "./manage.py sorcery", "downgrade", "tests.testapp", "-r", ":000000000000", "--no-color" ])
def test(self): out = six.StringIO() cmd = Downgrade(stdout=out) cmd.run_from_argv(["./manage.py sorcery", "downgrade", "--no-color"]) revs = db.execute( "select * from public.alembic_version_tests_testapp").fetchall() self.assertEqual(revs, []) Upgrade().run_from_argv( ["./manage.py sorcery", "upgrade", "--no-color"]) cmd.run_from_argv([ "./manage.py sorcery", "downgrade", "tests.testapp", "-r", "000000000000", "--no-color" ]) revs = db.execute( "select * from public.alembic_version_tests_testapp").fetchall() self.assertEqual(revs, [("000000000000", )])
def test_sql(self): out = six.StringIO() cmd = Downgrade(stdout=out) cmd.run_from_argv( ["./manage.py sorcery", "downgrade", "-s", "--no-color"]) out.seek(0) self.assertEqual( out.readlines(), [ "BEGIN;\n", "\n", "DROP TABLE alembic_version_tests_otherapp;\n", "\n", "COMMIT;\n", "\n", "BEGIN;\n", "\n", "DROP TABLE public.alembic_version_tests_testapp;\n", "\n", "COMMIT;\n", "\n", ], )