Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #67 (closed defect: fixed)

Opened 14 years ago

Last modified 12 years ago

Database app testing improvements

Reported by: kevin Owned by: anonymous
Priority: high Milestone: 0.9
Component: TurboGears Version:
Severity: normal Keywords:
Cc:

Description

TurboGears does not currently include any specific tools or support for testing the database aspect of your applications. There needs to be a way to setup and teardown the database as needed.

Some hints on this may be found in the testing utilities in sqlobject.

Attachments

__init__.py Download (453 bytes) - added by jchu@… 14 years ago.
DBTest class, to be used for test cases instead of unittest.TestCase?.
DBTest-fix.patch Download (1.0 KB) - added by jchu@… 14 years ago.
Patch for DBTest file commited in rev 186

Change History

comment:1 Changed 14 years ago by kevin

  • Priority changed from normal to high

Changed 14 years ago by jchu@…

DBTest class, to be used for test cases instead of unittest.TestCase?.

comment:2 Changed 14 years ago by jchu@…

The attached file needs one other change to the setup.py file: +import sys +import cherrypy +if len(sys.argv) > 1 and sys.argv[1] == "testgears": + cherrypy.config.update(file="dev.cfg") +

This version uses the existing dev database. It doesn't create tables, but always rolls back the changes for each test.

I have another version that creates the tables in a sqlite in memory database if that one pleases you more. All the changes for that one are in the init.py file.

comment:3 Changed 14 years ago by kevin

  • Status changed from new to assigned

comment:4 Changed 14 years ago by kevin

  • Status changed from assigned to closed
  • Resolution set to fixed

There's now a simple implementation of this that uses sqlite memory database. This will likely need extension to use other databases to be generally useful.

comment:5 Changed 14 years ago by jchu@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

Here is a patch to make DBTest work. Just to describe the changes:

  • A sqlite memory db is :memory: not memory.
  • type(item) == type doesn't quite make sense. I found inspect.isclass was the best way to check if something is a class (so that you can issubclass it).
  • The SQLObject class doesn't share our Hubs, so trying to .create_table it results in an error.

I have verified with this patch, my original tests all work like they used to.

Changed 14 years ago by jchu@…

Patch for DBTest file commited in rev 186

comment:6 Changed 14 years ago by elvelind@…

  • Status changed from reopened to closed
  • Resolution set to fixed

commited

Note: See TracTickets for help on using tickets.