Files
zulip/zerver/management/commands/get_migration_status.py
Tomasz Kolek dbeab6aa6f Optimize checks of test database state by moving into Python.
Previously, the generate-fixtures shell script by called into Django
multiple times in order to check whether the database was in a
reasonable state.  Since there's a lot of overhead to starting up
Django, this resulted in `test-backend` and `test-js-with-casper`
being quite slow to run a single small test (2.8s or so) even on my
very fast laptop.

We fix this is by moving the checks into a new Python library, so that
we can avoid paying the Django startup overhead 3 times unnecessarily.
The result saves about 1.2s (~40%) from the time required to run a
single backend test.

Fixes #1221.
2016-10-05 10:40:19 -07:00

25 lines
848 B
Python

# -*- coding: utf-8 -*-
import argparse
from typing import Any
from django.db import DEFAULT_DB_ALIAS
from django.core.management.base import BaseCommand
from zerver.lib.test_fixtures import get_migration_status
class Command(BaseCommand):
help = "Get status of migrations."
def add_arguments(self, parser):
# type: (argparse.ArgumentParser) -> None
parser.add_argument('app_label', nargs='?',
help='App label of an application to synchronize the state.')
parser.add_argument('--database', action='store', dest='database',
default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. '
'Defaults to the "default" database.')
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
self.stdout.write(get_migration_status(**options))