zacharyvoase / django-postgres

First-class Postgres feature support for the Django ORM.
http://django-postgres.readthedocs.org/
The Unlicense
183 stars 28 forks source link

sync_pgviews should catch the syncdb signal and run itself #5

Closed adamhaney closed 11 years ago

adamhaney commented 11 years ago

I'm running into a problem where the test runner is unaware of views that I've created, which is causing model validation issues and missing views that I can't write tests against. It seems the easiest way to fix this problem would be to have sync_pgviews catch syncdb and run itself in the least forceful way possible. I'd be more than happy to implement this if this seems like a good idea. My next try would be to implement a subclasses test runner (like south does). Any ideas?

scott-w commented 11 years ago

This conflicts with #3 which was implemented - essentially it conflicts with migrations.

I worked around this issue by extending TestCase.setUp() like so:

def setUp(self):
    call_command('sync_pgviews', *[], **{})
    # My other setup stuff here

Regards, Scott

zacharyvoase commented 11 years ago

So, catching the syncdb signal is what we used to do originally. However in order to be more compatible with migrations we switched to the separate sync_pgviews. So yeah, calling the command from setUp() is the best option for now. Don’t forget to call the supermethod if you’re using the South test runner.