diff options
author | Emily O'Leary <Emma.C.Echo@gmail.com> | 2013-06-25 20:57:50 -0400 |
---|---|---|
committer | Emily O'Leary <Emma.C.Echo@gmail.com> | 2013-06-25 20:57:50 -0400 |
commit | 4a698535bc97b37c8eb42ffea2cc3e7bd48565e6 (patch) | |
tree | 5ee573acc9f8c91cb53e44a1ee55529f3c74e5e1 /mediagoblin/gmg_commands/dbupdate.py | |
parent | c1b342ba95e99407ccedfdfad306ddb36fde6eb0 (diff) | |
download | mediagoblin-4a698535bc97b37c8eb42ffea2cc3e7bd48565e6.tar.lz mediagoblin-4a698535bc97b37c8eb42ffea2cc3e7bd48565e6.tar.xz mediagoblin-4a698535bc97b37c8eb42ffea2cc3e7bd48565e6.zip |
Improved test runtime from 352 seconds to 59 seconds by implementing an in-memory sqlite DB and including an option to run migrations on this newly created database by adding a config option called run_migrations to the config_spec and passing it along in app.py to the setup_database function.
Diffstat (limited to 'mediagoblin/gmg_commands/dbupdate.py')
-rw-r--r-- | mediagoblin/gmg_commands/dbupdate.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py index fa25ecb2..1d9bbf1e 100644 --- a/mediagoblin/gmg_commands/dbupdate.py +++ b/mediagoblin/gmg_commands/dbupdate.py @@ -110,14 +110,22 @@ def run_dbupdate(app_config, global_config): in the future, plugins) """ + # Set up the database + db = setup_connection_and_db_from_config(app_config, migrations=True) + #Run the migrations + run_all_migrations(db, app_config, global_config) + + +def run_all_migrations(db, app_config, global_config): + """ + Moved the migration part of run_dbupdate to a separate function so + it can be used to initialize the database during tests. + """ # Gather information from all media managers / projects dbdatas = gather_database_data( app_config['media_types'], global_config.get('plugins', {}).keys()) - # Set up the database - db = setup_connection_and_db_from_config(app_config, migrations=True) - Session = sessionmaker(bind=db.engine) # Setup media managers for all dbdata, run init/migrate and print info |