def test_save_returns_errors_if_error_ocurred_during_save(self): Collection.collection.create_index('test', unique=True) Collection.insert_one({'test': 'test'}) document = Document(Collection) document.test = 'test' errors = document.save() self.assertEqual(errors['error_code'], 0) self.assertEqual(errors['error_type'], 'PyMongoError') Collection.drop_index('test_1')
def test_set_attr_correctly_sets_field(self): document = Document(Collection) document.test = 1 self.assertEqual(document._fields['test'], 1)