Пример #1
0
def test_auto_increment_must_increment_id_of_new_documents(db):
    c = db.collection1

    c.insert({'_id':20})

    save_doc_with_autoincremented_id(c, {'field':'value'})
    assert c.find_one({'_id':21})['field'] == 'value'
Пример #2
0
def test_auto_increment_on_concurent_document_saves(db):
    c = db.collection1

    c.insert({'_id':20})

    def insert():
        c.save({'_id':21})

    save_doc_with_autoincremented_id(c, {'field':'value'}, insert)
    assert c.find_one({'_id':22})['field'] == 'value'
Пример #3
0
def test_auto_increment_must_not_change_id_of_existing_documents(db):
    c = db.collection1

    c.insert({'_id':20})
    doc = c.find_one({'_id':20})
    doc['field'] = 'value'
    save_doc_with_autoincremented_id(c, doc)

    assert c.find_one({'_id':20})['field'] == 'value'
    assert not c.find({'_id':21}).count()