refactor: Early-exit in update_test_databases_if_required.

Just make each conditional run what it needs to run.  The
simplicity that this provides will be more apparent
soon.
This commit is contained in:
Steve Howell
2020-04-21 20:45:37 +00:00
committed by Tim Abbott
parent 54151bb548
commit b10be1f8b7

View File

@@ -224,13 +224,19 @@ def update_test_databases_if_required(use_force: bool=False,
"""
generate_fixtures_command = ['tools/setup/generate-fixtures']
test_template_db_status = TEST_DATABASE.template_status()
if use_force or test_template_db_status == 'needs_rebuild':
generate_fixtures_command.append('--force')
elif test_template_db_status == 'run_migrations':
TEST_DATABASE.run_db_migrations()
elif not rebuild_test_database:
subprocess.check_call(generate_fixtures_command)
return
subprocess.check_call(generate_fixtures_command)
if test_template_db_status == 'run_migrations':
TEST_DATABASE.run_db_migrations()
subprocess.check_call(generate_fixtures_command)
return
if rebuild_test_database:
subprocess.check_call(generate_fixtures_command)
def get_migration_status(**options: Any) -> str:
verbosity = options.get('verbosity', 1)