Renamed Document._id to id (still _id in DB)
Although MongoDB uses _id, underscore prefixed attributes imply private access in Python and are sometimes may not be accessed (e.g. in the Django template language), but id should be public.
This commit is contained in:
@@ -46,10 +46,10 @@ class FieldTest(unittest.TestCase):
|
||||
name = StringField()
|
||||
|
||||
person = Person(name='Test User')
|
||||
self.assertRaises(AttributeError, getattr, person, '_id')
|
||||
self.assertRaises(ValidationError, person.__setattr__, '_id', 47)
|
||||
self.assertRaises(ValidationError, person.__setattr__, '_id', 'abc')
|
||||
person._id = '497ce96f395f2f052a494fd4'
|
||||
self.assertRaises(AttributeError, getattr, person, 'id')
|
||||
self.assertRaises(ValidationError, person.__setattr__, 'id', 47)
|
||||
self.assertRaises(ValidationError, person.__setattr__, 'id', 'abc')
|
||||
person.id = '497ce96f395f2f052a494fd4'
|
||||
|
||||
def test_string_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to string fields.
|
||||
|
||||
Reference in New Issue
Block a user