Exemple #1
0
    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')
Exemple #2
0
    def test_save_returns_fields_if_document_has_id_and_is_valid(self):
        document = Document(Collection)
        document._id = ObjectId()
        fields = document.save()

        self.assertEqual(fields, document._fields)