diff --git a/README.rst b/README.rst index dc7ac3a..24eed16 100644 --- a/README.rst +++ b/README.rst @@ -105,7 +105,7 @@ command line. # Add a document using the batch upload SDF: curl -X POST -H "Content-Type: application/json" http://localhost:15808/2013-08-22/documents/batch -d '[{"lang": "en", "fields": {"name": "bob"}, "version": 1376497963, "type": "add", "id": 1246}]' - {"status": "ok", "adds": 1, "deletes": 0, "error": "", "warning": ""} + {"status": "success", "adds": 1, "deletes": 0, "errors": [], "warnings": []} # Check the document is there: curl http://localhost:15808/dev/documents @@ -120,7 +120,7 @@ command line. # Remove the document in another batch update: curl -X POST -H "Content-Type: application/json" http://localhost:15808/2013-08-22/documents/batch -d '[{"version": 1376497963, "type": "delete", "id": 1246}]' - {"status": "ok", "adds": 0, "deletes": 1, "error": "", "warning": ""} + {"status": "success", "adds": 0, "deletes": 1, "errors": [], "warnings": []} # Check what was removed: curl http://localhost:15808/dev/documents diff --git a/nozama/cloudsearch/data/document.py b/nozama/cloudsearch/data/document.py index 100d02b..5a69580 100644 --- a/nozama/cloudsearch/data/document.py +++ b/nozama/cloudsearch/data/document.py @@ -189,16 +189,16 @@ def load(docs_to_load): .. code-block:: python rc = dict( - status='ok', + status='success', adds=len(to_load), deletes=len(to_remove), - error='', - warning='', + errors=[], + warnings=[], ) Reference: - * http://docs.aws.amazon.com/cloudsearch/latest/developerguide/\ - DocumentsBatch.JSON.html#DocumentsBatch.JSON.ResponseProperties + * https://docs.aws.amazon.com/cloudsearch/latest/developerguide/\ + documents-batch-resource.html#documents-batch-json-response-properties """ log = get_log('load') @@ -244,11 +244,11 @@ def load(docs_to_load): remove_from_elasticsearch(doc) rc = dict( - status='ok', + status='success', adds=len(to_load), deletes=len(to_remove), - error='', - warning='', + errors=[], + warnings=[], ) return rc diff --git a/requirements.txt b/requirements.txt index cbee0ef..f8e5ddd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -pymongo -elasticsearch +pymongo~=3.0 +elasticsearch~=7.0 decorator paste formencode diff --git a/tests/test_backend_searching.py b/tests/test_backend_searching.py index ff1d414..2631d55 100644 --- a/tests/test_backend_searching.py +++ b/tests/test_backend_searching.py @@ -66,7 +66,7 @@ def test_basic_search(logger, mongodb, elastic): ] rc = document.load(example_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 2 # return all: diff --git a/tests/test_documentops.py b/tests/test_documentops.py index 4e43e5d..3e0c9e9 100644 --- a/tests/test_documentops.py +++ b/tests/test_documentops.py @@ -36,11 +36,11 @@ def test_document_add(logger, elastic, mongodb): rc = document.load(example_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 1 assert rc['deletes'] == 0 - assert rc['error'] == '' - assert rc['warning'] == '' + assert rc['errors'] == [] + assert rc['warnings'] == [] found = document.all() @@ -71,11 +71,11 @@ def test_remove_on_emtpy(logger, mongodb): ] rc = document.load(example_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 0 assert rc['deletes'] == 1 - assert rc['error'] == '' - assert rc['warning'] == '' + assert rc['errors'] == [] + assert rc['warnings'] == [] found = document.all() assert len(found) == 0 @@ -118,11 +118,11 @@ def test_add_remove(logger, mongodb): rc = document.load(example_add_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 1 assert rc['deletes'] == 0 - assert rc['error'] == '' - assert rc['warning'] == '' + assert rc['errors'] == [] + assert rc['warnings'] == [] report = document.report() @@ -142,11 +142,11 @@ def test_add_remove(logger, mongodb): ] rc = document.load(example_remove_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 0 assert rc['deletes'] == 1 - assert rc['error'] == '' - assert rc['warning'] == '' + assert rc['errors'] == [] + assert rc['warnings'] == [] found = document.all() assert len(found) == 0 @@ -199,11 +199,11 @@ def test_remove_then_search(logger, mongodb): rc = document.load(example_add_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 1 assert rc['deletes'] == 0 - assert rc['error'] == '' - assert rc['warning'] == '' + assert rc['errors'] == [] + assert rc['warnings'] == [] report = document.report() @@ -223,11 +223,11 @@ def test_remove_then_search(logger, mongodb): ] rc = document.load(example_remove_sdf) - assert rc['status'] == 'ok' + assert rc['status'] == 'success' assert rc['adds'] == 0 assert rc['deletes'] == 1 - assert rc['error'] == '' - assert rc['warning'] == '' + assert rc['errors'] == [] + assert rc['warnings'] == [] found = document.all() assert len(found) == 0