mirumee / django-prices

Django fields for the prices module
158 stars 53 forks source link

Write tests involving models with TaxedMoneyField and save()/delete() calls #58

Open rafalp opened 6 years ago

rafalp commented 6 years ago

During work on updating Saleor's codebase to use current prices, I've ran into plenty of edge cases with Django ORM accessing different attributes on TaxedMoneyField instances when running different operations.

Those could've been found much sooner if our test suite included following scenarios:

  1. model.save()
  2. model.save(update_fields)
  3. model.delete()

We should also explore how behavior of those changes for models that are:

  1. pointed to by ForeignKey in other model
  2. are pointing to other model via ForeignKey

This is because Django's ORM appears to look up related models fields, iterating on them and snooping out different attrs for its checks and validations.