Tested Model.set_FOO_order() with an unrelated object.

This commit is contained in:
Tim Graham 2019-01-21 14:00:18 -05:00
parent 130192b12b
commit 2110b17924
1 changed files with 7 additions and 0 deletions

View File

@ -50,6 +50,13 @@ class BaseOrderWithRespectToTests:
a2 = self.Answer.objects.create(text="Number five", question=self.q1)
self.assertEqual(list(a1.question.get_answer_order()), list(a2.question.get_answer_order()))
def test_set_order_unrelated_object(self):
"""An answer that's not related isn't updated."""
q = self.Question.objects.create(text='other')
a = self.Answer.objects.create(text='Number five', question=q)
self.q1.set_answer_order([o.pk for o in self.q1.answer_set.all()] + [a.pk])
self.assertEqual(self.Answer.objects.get(pk=a.pk)._order, 0)
def test_change_ordering(self):
# The ordering can be altered
a = self.Answer.objects.create(text="Number five", question=self.q1)