From 239474124ee50dd2de1c2dbb6f87d70811abe852 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 21 Apr 2020 21:04:42 +0000 Subject: [PATCH] test-backend: Remove generate_fixtures option. We remove the `generate_fixtures` option here mostly for simplicity, but in particular to facilitate an upcoming commit to simplify the job of `generate-fixtures` (and remove its `--force` option). The command line option here for `test-backend` was really calling `generate_fixtures --force`, which we're about to rename `tools/rebuild-test-database`. The `test-backend` tools is already smart about catching up on migrations, so we generally don't need to tell it to repair the database. And if the database does get corrupt, you can just do it directly with `tools/rebuild-test-database`. This eliminates the `use_force` flag in `update_test_databases_if_required`, which was easy to confuse with `rebuild_test_database`. The other caller wasn't using `use_force`. --- tools/test-backend | 5 +---- zerver/lib/test_fixtures.py | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/test-backend b/tools/test-backend index e3ce1c4dae..15f82eaa05 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -238,9 +238,6 @@ def main() -> None: action="store_true", default=False, help="Show detailed output") - parser.add_argument('--generate-fixtures', action="store_true", default=False, - dest="generate_fixtures", - help=("Force a call to generate-fixtures.")) parser.add_argument('--report-slow-tests', dest='report_slow_tests', action="store_true", default=False, @@ -377,7 +374,7 @@ def main() -> None: # files, since part of setup is importing the models for all applications in INSTALLED_APPS. django.setup() - update_test_databases_if_required(options.generate_fixtures) + update_test_databases_if_required() subprocess.check_call(['tools/webpack', '--test']) diff --git a/zerver/lib/test_fixtures.py b/zerver/lib/test_fixtures.py index a216b31e9d..fa5b2c9f7e 100644 --- a/zerver/lib/test_fixtures.py +++ b/zerver/lib/test_fixtures.py @@ -202,8 +202,7 @@ TEST_DATABASE = Database( settings='zproject.test_settings', ) -def update_test_databases_if_required(use_force: bool=False, - rebuild_test_database: bool=False) -> None: +def update_test_databases_if_required(rebuild_test_database: bool=False) -> None: """Checks whether the zulip_test_template database template, is consistent with our database migrations; if not, it updates it in the fastest way possible: @@ -219,12 +218,10 @@ def update_test_databases_if_required(use_force: bool=False, The `rebuild_test_database` option (used by our Casper tests) asks us to drop and re-cloning the zulip_test database from the template so those test suites can run with a fresh copy. - - If use_force is specified, it will always do a full rebuild. """ test_template_db_status = TEST_DATABASE.template_status() - if use_force or test_template_db_status == 'needs_rebuild': + if test_template_db_status == 'needs_rebuild': run(['tools/rebuild-dev-database']) return