KristianOellegaard/django-hvad — pull request #194 by spectras (2014-07-05 09:20:12+00:00)
Title: Rework the handling of fixtures in tests

Fixtures in the test have gone wild for awhile. Now it's gotten a bit messy: testcases building their own fixtures, or only half of it, random test string running around. Also, a lot of tests rely on the value of the public key, which breaks on PostgreSQL. Not to mention the sequence tests on unsorted querysets.

This patch fixes it all :-)
- models for the test project got some sorting and commenting so we know what they are for.
- data for fixtures is now cleanly organized, using `namedtuple`s for better readability.
- fixtures were made generic and parameterizable. No more `SingeTranslatedNormalWithOnStandardMixin`. Rather, a testcase includes `NormalFixture` and `StandardFixture` and sets a `normal_count` and `standard_count` attribute to configure them.
- fixture ids are now available directly on the testcase, in `self.normal_id`, `self.standard_id` and so on dictionnaries. No more (wrong) guessing at the id assigned by the db.
- all tests are updated according to the above changes.
- a large part of the tests that built their own fixtures now use the common ones.
- tests that were testing unordered querysets now count the items instead of comparing for equality and relying on default database ordering (which is not guaranteed).

As a result, the testsuite now passes on PostgreSQL for Django >= 1.4. Django 1.3 won't even create the test db though, it is too old for PostgreSQL 9.1.