From 2110b1792422a8c358795c895d63fb75df51af9a Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 21 Jan 2019 14:00:18 -0500 Subject: [PATCH] Tested Model.set_FOO_order() with an unrelated object. --- tests/order_with_respect_to/base_tests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/order_with_respect_to/base_tests.py b/tests/order_with_respect_to/base_tests.py index 94f3c579e2..be67b068de 100644 --- a/tests/order_with_respect_to/base_tests.py +++ b/tests/order_with_respect_to/base_tests.py @@ -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)