BartKrol / tvmanager

Favourite shows tracking webapp
MIT License
2 stars 2 forks source link

Add Factories #7

Open jakzale opened 9 years ago

jakzale commented 9 years ago

Factory Boy provides nice factories, but its integration with SQLAlchemy is somewhat weird.

jakzale commented 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

jakzale commented 9 years ago

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?

BartKrol commented 9 years ago

Diffeeent db objects are created in config (look at settings/config).

Did you look for flask factory boy guide?

jakzale commented 9 years ago

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?

jakzale commented 9 years ago

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.

jakzale commented 9 years ago

This turns out to be slightly more complicated. (See #8)

jakzale commented 9 years ago

Probably needs #15 first.