alphagov/stagecraft — pull request #120 by paulfurley (2014-04-29 15:12:17+00:00)
Title: Make tests work on PostgreSQL

https://www.pivotaltracker.com/story/show/67995534

The problem was related to how we created a temporary DataType and DataGroup
at the start of a test class, then shared it between tests. This coupling
between tests meant that one test could break another one. It went unnoticed
in SQLite because it doesn't enforce certain foreign key constraints.

I've refactored the code so that the `_make_temp_data_group_and_type` creates
a data type/group with a long random name, and no longer deletes it
afterwards (because this was hitting database PROTECT integrity errors).

Now instead of sharing a data type/group between tests in a test class, each
test just asks for a new pair and will always get a unique pair. This
decouples the tests from each other and makes it work in PostgreSQL.

[Fixes #67995534]