def test_delete(client: CouchClient, async_run: Callable): doc = async_run(client.doc_get(db_name, doc_name)) assert doc.status_code == 200 response = async_run(client.doc_delete(db_name, doc_name, doc.model._rev)) assert response.status_code == 200 assert response.model.ok is True response = async_run(client.doc_delete(db_name, doc_name, doc.model._rev)) assert response.status_code == 404
def test_get(client: CouchClient, async_run: Callable): response = async_run(client.doc_get(db_name, doc_name, attachments=True, att_encoding_info=True, conflicts=True, deleted_conflicts=True, latest=True, local_seq=True, meta=True, revs=True, revs_info=True)) assert response.status_code == 200 assert response.model._id == doc_name assert response.model.doc.get('val') == 2 response = async_run(client.doc_get(db_name, 'invalid_%%%_name')) assert response.status_code == 404 response = async_run(client.doc_get(db_name, 'non_existing')) assert response.status_code == 404
def test_create_with_attachments(client: CouchClient, async_run: Callable): attachments = MultipartRelatedAttachment( name=b'text', data=b'test_text', mime_type=b'text/plain') response = async_run(client.doc_create_or_update( db_name, doc_with_attachments, dict(val=-1), attachments=[attachments] )) assert response.status_code == 201 assert response.model.ok is True response = async_run(client.doc_get( db_name, doc_with_attachments, attachments=True)) assert response.status_code == 200 assert response.model._files[1].decode() == attachments.data
def test_copy(client: CouchClient, async_run: Callable): original = async_run(client.doc_get(db_name, doc_name)) assert original.status_code == 200 response = async_run(client.doc_copy( db_name, doc_name, 'test_copy', rev=original.model._rev)) assert response.model.ok is True assert response.status_code == 201 copied = async_run(client.doc_get(db_name, 'test_copy')) assert copied.status_code == 200 assert copied.model.doc.get('val') == original.model.doc.get('val') assert copied.model.doc.get('val') == 2 response = async_run(client.doc_copy( db_name, doc_name, 'test_copy2', batch='ok')) assert response.model.ok is True # todo: returns 201 rather then 202 # assert response.status_code == 202 response = async_run(client.doc_copy( db_name, 'non_existing', 'test_new_copy')) assert response.status_code == 404