Matt Wilson schrieb:
> Hi --
> 
> I wanted to write some tests on my model that would depend on my real
> database.  I eventually figured out that the database.set_db_uri(...)
> line needed to preced the import model line in order to make sure that
> my real database
> 
> The testutil.DBTest has a built-in teardown method that attempts to
> delete every table.  This is not good if I am going to use a real
> database!

This is an ever recurring problem with unit-tests that involve 
databases. Against what DB do you run the tests, do you allow for 
changes in there, will you recreate the DB every time or keep it around 
- and so forth.

I think TG has made a sound decision here to use sqlite + recreating the 
  DB.

And I don't see a reason why you don't follow that. You can create and 
drop a special test-schema in the postgres as well.

> Meanwhile, when I used sqlite to write some other tests and I ran into
> a different problem. My model has this line in it:
> 
> short_descriptionIndex =
> DatabaseIndex({'expression':'lower(short_description)'}, unique=True)
> 
> which gets translated into this SQL:
> 
> CREATE UNIQUE INDEX category_short_descriptionIndex ON category
> (lower(short_description))
> 
> That statement is valid in postgres but not in sqlite.  sqlite
> complained about a syntax error.
> 
> I'm not posting this to complain pointlessly.  I'm happy to work on
> the solution if others agree that these are problems.
> 
> Maybe I'm just using the framework incorrectly.

this is another general problem, this time of ORMs. What you use is very 
specific to postgres - there is no way to abstract that in a way that 
makes the ORM work with all kinds of DBs.

If you follow my advice above and use a dedicated, volatile test-schema, 
both of your problems will vanish.

Diez

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to