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
--
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en.