Opened 12 years ago
Last modified 12 years ago
#614 closed defect
Ability to swap app configuration for different unit tests — at Version 2
Reported by: | Christopher Allan Webber | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 0.4.0 |
Component: | programming | Keywords: | pluginapi |
Cc: | Parent Tickets: |
Description (last modified by )
We need the ability to load different app configurations for different types of tests.
This sounds easier than it is; technically we should be able to just have the function in mediagoblin.tests.tools that loads the mediagoblin app (get_app
) just use a different configuration that we specify. However, it isn't that easy for SQLAlchemy reasons. We currently use the "cascading delete" feature in SQLAlchemy... however, if we load one "application" that has the video media type enabled, then that imports and sees the VideoData
table. If we create another mediagoblin app instance without the video media type enabled, sqlalchemy will try to delete related entries during a cascading delete from the videodata table but won't be able to and will thus throw an exception.
There's one of two solutions to this:
- Figure out how to fiddle with sqlalchemy's metadata information to add/remove the link manually.
- Don't use sqlalchemy's built in cascading delete and roll our own instead. We could have models register themselves on a method's delete registry so that when deleted in our "manual cascading" pattern it'll be smart about it.
I'd like this fixed soon so we can start writing proper tests for plugins.
Change History (2)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Description: | modified (diff) |
---|
Two options for fiddling with the metadata:
.clear()
(http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html#sqlalchemy.schema.MetaData.clear) and then reload all models to repopulate the metadata..remove(table)
can be used to remove the tables that aren't any more of interest: http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html#sqlalchemy.schema.MetaData.removeAlso the metadata has a list of tables: http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html#sqlalchemy.schema.MetaData.sorted_tables
This all should be implemented in
open.py
because it has the knowledge to reload tables and or know the tables that should exist.Just my few bits. Haven't tested anything.