Fix ValueError in tests when assigning unsaved instance
Django now throws a ValueError when an unsaved instance is assigned:
https://docs.djangoproject.com/en/1.8/releases/1.8/#assigning-unsaved-objects-to-relations-raises-an-error
This commit changes the offending lines to create objects in the
database instead. But I don't understand why I don't need to make
the same changes for e.g. the country factory.
But I don't really care, as long as the tests pass. I'm guessing it has
something to do with factory-boy and the get_or_create statement.
Unfortunately, this will make our test suite slower. But to make up for
it, Django 1.8 introduces the setUpTestCase method, which we can use
once Django 1.7 is removed.
Don't create objects in the database unless necessary
Conflicts:
oscar/apps/offer/models.py
tests/integration/offer/combination_tests.py
tests/integration/offer/percentage_benefit_tests.py
@maikhoepfel duplicated the proxy class short-circuit logic for
Conditions as part of this commit.
Cherry-picked from #1414.
Hmmm, this turned out to be a monster commit. This change allows the
basket to be able to correctly calculate prices including tax.
It also requires a whole load of test changes since all baskets now
require a strategy instance to be assigned.
This allows updating code in both places, if necessary. Getting Django
1.5 support would be painful otherwise. This also removes the circular
dependency of django-oscar-testsupport on Oscar.
The requirements were merged. The imports were updated
accordingly. Unused imports in the touched files were removed. No
further changes.
This allows the total discount of an offer to be capped. It's a
slightly odd mechanism as the offer only becomes inactive once the cap
is exceeded, and it's possible that it is exceeded by a lot.
However, it's still a useful construct for managing offers.
This is a major clean-up of offers, tidying up the implementations and
rewriting the test suite. This should also clean up some edge cases
around the use of max_affected_items.