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 #1892 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

[PATCH]: apply all constraints in testutil.dbtest after creating all tests

Reported by: mw44118 Owned by: kskuhlman
Priority: normal Milestone: 1.0.x bugfix
Component: TurboGears Version: 1.0 HEAD
Severity: normal Keywords: needs tests
Cc:

Description (last modified by Chris Arndt) (diff)

I have two tables with foreign keys that refer to each other. I need to create both tables before I apply the FK constraints.

SQLObject docs describe how to do this here:  http://sqlobject.org/FAQ.html#mutually-referencing-tables

This patch alters testutil so it waits for all tables to be created before it adds any constraints.

Attachments

my_patch.diff Download (1.2 KB) - added by mw44118 11 years ago.
Waits until all tables are created to go back and add FK constraints.

Change History

Changed 11 years ago by mw44118

Waits until all tables are created to go back and add FK constraints.

comment:1 Changed 11 years ago by kskuhlman

  • Owner changed from anonymous to kskuhlman

comment:2 Changed 11 years ago by Chris Arndt

A few comments on the patch:

  • There should be a source code comment explaining what's going on.
  • The if istance(..) body is indented incorrectly.
  • applyConstraints=0 should be applyConstraints=False according to the linked SQLObject documentation.
  • constraints += postponed_constraint should be written a contraints.extends(postponed_constraint).

Also, a test is missing.

comment:3 Changed 11 years ago by mw44118

I'll resubmit the patch with the first few points.

I'm not sure how to write a test for this code. If you outline what is involved, I'll take a shot at it.

comment:4 Changed 11 years ago by Chris Arndt

  • Description modified (diff)
  • Milestone set to 1.1

See  http://docs.turbogears.org/1.1/Testing on how to write test for TG 1.1. You need to create and example model with mutually referencing tables and then write test methods which check if the setUp method of the test class correctly created the model.

The test should go into the turbogears.tests.test_model module.

comment:5 Changed 11 years ago by Chris Arndt

  • Keywords needs tests added
  • Milestone changed from 1.1 to 1.1 beta 2

comment:6 Changed 11 years ago by faide

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

Applied in r5662

I did not see how to test test testutil sytem itself, so I just vefified the tests passed and fixed my errors :)

I committed a modified version with more proper code and more docstrings.

comment:7 Changed 10 years ago by mw44118

  • Status changed from closed to reopened
  • Version changed from 1.0.4.4 to 1.0 HEAD
  • Resolution fixed deleted
  • Milestone changed from 1.1b2 to 1.0.x bugfix

This patch wasn't applied to the 1.0 branch. Can somebody add it in?

comment:8 Changed 10 years ago by chrisz

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

Done in r6298.

Note: See TracTickets for help on using tickets.