Fix the duplicate ListField max_length test (#2110)
This is a follow-up after #2107.
Not sure what happened here, but in
87194856ec
I committed a copy-paste of the same test instead of a test validating the
max_length behavior along with a "set" operator.
This commit is contained in:
parent
82f0eb1cbc
commit
609f50d261
@ -1026,21 +1026,16 @@ class FieldTest(MongoDBTestCase):
|
||||
foo.save()
|
||||
self.assertIn("List is too long", str(cm.exception))
|
||||
|
||||
def test_list_field_max_length(self):
|
||||
"""Ensure ListField's max_length is respected."""
|
||||
def test_list_field_max_length_set_operator(self):
|
||||
"""Ensure ListField's max_length is respected for a "set" operator."""
|
||||
|
||||
class Foo(Document):
|
||||
items = ListField(IntField(), max_length=5)
|
||||
items = ListField(IntField(), max_length=3)
|
||||
|
||||
foo = Foo()
|
||||
for i in range(1, 7):
|
||||
foo.items.append(i)
|
||||
if i < 6:
|
||||
foo.save()
|
||||
else:
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
foo.save()
|
||||
self.assertIn("List is too long", str(cm.exception))
|
||||
foo = Foo.objects.create(items=[1, 2, 3])
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
foo.modify(set__items=[1, 2, 3, 4])
|
||||
self.assertIn("List is too long", str(cm.exception))
|
||||
|
||||
def test_list_field_rejects_strings(self):
|
||||
"""Strings aren't valid list field data types."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user