コード例 #1
0
    def tearDown(self):
        super(TestStamp, self).tearDown()

        Downgrade().run_from_argv(
            ["./manage.py sorcery", "downgrade", "--no-color"])
        self.delete_migration("{}_.py".format("000000000000"))
        Downgrade().run_from_argv(
            ["./manage.py sorcery", "downgrade", "--no-color"])
コード例 #2
0
    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"
            ])
コード例 #3
0
 def tearDown(self):
     super().tearDown()
     Downgrade().run_from_argv([
         "./manage.py sorcery", "downgrade", "tests_testapp", "--no-color"
     ])
     for rev in ["000000000000", "000000000001"]:
         self.delete_migration("{}_zero.py".format(rev))
     Downgrade().run_from_argv([
         "./manage.py sorcery", "downgrade", "tests_testapp", "--no-color"
     ])
コード例 #4
0
 def setUp(self):
     super().setUp()
     for rev in ["000000000000", "000000000001"]:
         self.write_migration(MIGRATION.format(rev=rev),
                              "{}_zero.py".format(rev))
         self.write_migration(MIGRATION.format(rev=rev),
                              "{}_zero.py".format(rev))
     Downgrade().run_from_argv([
         "./manage.py sorcery", "downgrade", "tests_testapp", "--no-color"
     ])
コード例 #5
0
    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",
            ],
        )
コード例 #6
0
    def setUp(self):
        super().setUp()

        for rev in ["000000000000", "000000000001"]:
            self.delete_migration("{}_.py".format(rev))

        self.write_migration(M1, "{}_.py".format("000000000000"))
        self.write_migration(M2, "{}_.py".format("000000000001"))

        Downgrade().run_from_argv([
            "./manage.py sorcery", "downgrade", "tests_testapp", "--no-color"
        ])

        Upgrade().run_from_argv(
            ["./manage.py sorcery", "upgrade", "tests_testapp", "--no-color"])
コード例 #7
0
    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", )])
コード例 #8
0
 def tearDown(self):
     super().tearDown()
     self.delete_migration("{}_.py".format(rev))
     self.delete_migration("{}_zero.py".format(rev))
     Downgrade().run_from_argv(
         ["./manage.py sorcery", "downgrade", "--no-color"])