Open jakzale opened 9 years ago
Factories require their own session object. Currently we use Flask-SQLAlchemy which simplifies use of sessions.
Maybe I should add test-specific scoped_sessions
db.Model
corresponds to declarative_base
so that is sorted out.
db.engine
should be the default engine. But then, should not test be run on a separate database?
Diffeeent db objects are created in config (look at settings/config).
Did you look for flask factory boy guide?
Ok, I was not sure if we have separate environments for testing set up.
There is a guide for sql alchemy (not flask specific): http://factoryboy.readthedocs.org/en/latest/orms.html#sqlalchemy
In general, they suggest using a global scoped_session, but then if we have a separate database, then it should be available as db.session
global object, shouldn't it?
Started working on f2eab4f086478748c9f1cdf009629694fcee1e5b
Not too happy about having a module factories
inside app/main/test
. Might get confused with the factory
module for factory boy. But then, the test cases should not reference factory boy directly.
This turns out to be slightly more complicated. (See #8)
Probably needs #15 first.
Factory Boy provides nice factories, but its integration with SQLAlchemy is somewhat weird.