← Back to team overview

launchpad-dev team mailing list archive

database layer resetting sequences & cronjob tests

 

This is a fairly hard problem to recreate.

Starting with two test methods in a single test class:
1. The first test method runs a cron script
2. The cron script succeeds and inserts a row into the ScriptActivity
table (performed by LaunchpadCronScript)
3. The database layer resets the sequences to the value that the
sequence had before it called the test method.
4. The second test method runs a cron script.
5. The cron script tries to insert a row into the ScriptActivity but
the sequence for the primary key was reset, but the previously added
rows in the ScriptActivity table still exist, so it fails.

I see that I can set DatabaseLayer._reset_between_tests to False. Is
this the preferred way to solve this problem?

-Edwin



Follow ups