コード例 #1
0
    def test_with_range_noapp(self):
        out = six.StringIO()

        cmd = Command(stdout=out)

        with self.assertRaises(SystemExit):
            cmd.run_from_argv(["./manage.py sorcery", "history", "-r", "base:head", "--no-color"])
コード例 #2
0
    def test_not_alembic_app(self):
        out = six.StringIO()
        err = six.StringIO()

        cmd = Command(stdout=out, stderr=err)

        with self.assertRaises(SystemExit):
            cmd.run_from_argv(["./manage.py sorcery", "history", "foo", "--no-color"])

        err.seek(0)
        self.assertEqual(err.readlines(), ["CommandError: App 'foo' could not be found. Is it in INSTALLED_APPS?\n"])
コード例 #3
0
    def test_bad_range(self):
        out = six.StringIO()
        err = six.StringIO()

        cmd = Command(stdout=out, stderr=err)

        with self.assertRaises(SystemExit):
            cmd.run_from_argv(["./manage.py sorcery", "history", "tests.testapp", "-r", "base-head", "--no-color"])

        err.seek(0)
        self.assertEqual(err.readlines(), ["CommandError: History range requires [start]:[end], [start]:, or :[end]\n"])
コード例 #4
0
    def test_with_range(self):
        out = six.StringIO()

        cmd = Command(stdout=out)

        cmd.run_from_argv(["./manage.py sorcery", "history", "tests.testapp", "-r", "base:head", "--no-color"])

        out.seek(0)
        self.assertEqual(
            out.readlines(),
            ["Migrations for tests.testapp on database test\n", "<base> -> 000000000000 (zero) (head), zero\n"],
        )