Added a test for a lookup in Model.refresh_from_db(fields=[...]).

This commit is contained in:
Hasan Ramezani 2018-11-15 17:38:47 +01:00 committed by Tim Graham
parent e1fc07c047
commit cf915cb513
1 changed files with 6 additions and 0 deletions

View File

@ -649,6 +649,12 @@ class ModelRefreshTests(TestCase):
with self.assertRaisesMessage(TypeError, msg):
s.refresh_from_db(unknown_kwarg=10)
def test_lookup_in_fields(self):
s = SelfRef.objects.create()
msg = 'Found "__" in fields argument. Relations and transforms are not allowed in fields.'
with self.assertRaisesMessage(ValueError, msg):
s.refresh_from_db(fields=['foo__bar'])
def test_refresh_fk(self):
s1 = SelfRef.objects.create()
s2 = SelfRef.objects.create()