Iwan
unread,Jul 9, 2011, 10:02:47 AM7/9/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to SQLElixir
Hi there,
We have a system which uses Elixir. When we test this system, our
tests usually do a setup_all and create_all (after importing all the
application's classes) - and this works fine.
However, we also want to create new classes (deriving from Entity or
one of our application's Entity classes) - just temporarily for a
particular test. We're having some trouble setting up such classes.
For a normal class (no inheritance), all works fine. It goes like
this: The test class would be declared in a method (of the test
fixture). The test using it will call the method to get the class
created, and then call setup_entities() with the new class, then
create_all(). No problem. (All of this gets rolled back before the
next test.)
But in the case where the test class inherits (multi) from another,
setup_entities does not set it up. Seemingly because the new entity
inherits a _setup_done attribute from its parent class.
We've tried all sorts of things to force the setup, but then other
things break...
Any ideas how we can handle this issue?
PS: this is on elixir 0.7.1 and alchemy 0.5.8
Below is an example illustrating this behaviour:
from elixir import *
metadata.bind = "sqlite:///:memory:"
class Movie(Entity):
using_options(inheritance = 'multi')
setup_all()
create_all()
print Movie.query.all()
def create_unrelated_test_class(): # This is how a temporary test
class would be defined
class TestClass(Entity):
pass
return TestClass
TestClass = create_unrelated_test_class() # ... and how it would be
set up
setup_entities([TestClass])
create_all()
print TestClass.query.all()
def create_test_movie_class():
class TestMovie(Movie):
using_options(inheritance = 'multi')
return TestMovie
TestMovie = create_test_movie_class()
setup_entities([TestMovie])
create_all()
print TestMovie.query.all() # breaks