This works for creating the table structure, and that is important,
but for me I think the actual data in the database is just was
important if not more so. What are people using to populate the
database with test data to use in the tests?

For example in my current application the "real" version would have
multiple gigabytes of data.  I don't need this much available but I am
going to have to find a way to populate the data base in some way with
a few MB of data for the tests.

I had considered just making my setup and teardown methods run through
an entire database load step. Perhaps just running through an sql
command file generated from pg_dump or something similar.

I started looking at PdbSeed (http://qualitylabs.org/pdbseed/) but it
appears to be tied to MySQL.  I was hoping that someone may have
something similar for use with SA.

Thanks,
Allen

On 2/2/07, Christopher Arndt <[EMAIL PROTECTED]> wrote:
>
> Allen schrieb:
> > How do people writing db applications with SA do unit testing on their
> > code?  Are there any good db unit testing frameworks that work well
> > with SA?  If I can't find anything I will probably just roll my own
> > but I would like to keep from reinventing the wheel if I can help it.
>
> Basically you have to initialize your database for each test and destroy it
> afterwards again (otherwise it wouldn't be a 'unit' test). In the 'unittest'
> module, you can use the 'setUp' and tearDown' methods of the TestCase class 
> for
> this purpose.
>
> For example:
>
> # model contains the SA table and mapper classes
> import unittest
> import sqlalchemy
> import model
>
> class SATestCase(unittest.TestCase):
>
>     def setUp(self):
>         # do what you have to do to bind the metadata/engine to the model here
>
>         # create all model tables
>         for item in dir(self.model):
>             item = getattr(self.model, item)
>             if isinstance(item, sqlalchemy.Table):
>                 item.create(checkfirst=True)
>
>     def tearDown(self):
>         # drop all model tables
>         for item in dir(self.model):
>             item = getattr(self.model, item)
>             if isinstance(item, sqlalchemy.Table):
>                 item.drop(checkfirst=True)
>         # close database
>
>     def testFoo(self):
>         # here comes your unit test
>
>
> Chris
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to