Hi,
I've been struggling with writing tests for a Child object that has
a mandatory Parent. The problem is usually around the Child having
something like
parent_id = Column(Integer, ForeignKey('parents.id'), nullable=False)
Probably very sensible from an application viewpoint but testing always
breaks because it only creates one object at a time.
I'm not sure if it is the right way, but this seemed to work for testing
the Child.
class TestChild(ModelTest):
klass = model.Child
test_parent = model.Parent()
attribs = dict(
parent = test_parent
...and so on. SQLAchemy is happy because there is not a null for
parent_id and I can actually test the Child object.
Someone should hopefully confirm this is how you do this sort of
testing. It works, but it doesn't mean it should work (or you should do
it that way)
- Craig
--
Craig Small VK2XLZ http://www.enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 1C1B D893 1418 2AF4 45EE 95CB C76C E5AC 12CA DFA5
--
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en.