samedi 9 décembre 2017

Why doesn't custom save method update another model while running Django test?

I have a custom save method on one model that updates the value of another model based on whether the current model is created or updated. I am trying to run a test to see if the value changes. Here is my code in the test.

test.py

yr.__setattr__('quantity_rcv', 200)
yr.save()
self.assertEqual(yr.quantity_rcv, lc_item.yarn_rcv)

Over here lc_item.yarn_rcv should have changed to the yr.quantity_rcv value based on the custom save method which works fine when I test it with Django admin.

Is the custom save method not working when I run test?

Aucun commentaire:

Enregistrer un commentaire