From 678d929f1b136c82cce5d2a787d4a667605408d1 Mon Sep 17 00:00:00 2001 From: Bastien Abadie <bastien@nextcairn.com> Date: Mon, 19 Oct 2020 16:00:00 +0000 Subject: [PATCH] Use arkindex API client 1.0.4 --- requirements.txt | 2 +- tests/test_elements_worker.py | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index eeca2aeb..e3bc00f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -arkindex-client==1.0.3 +arkindex-client==1.0.4 Pillow==7.2.0 python-gnupg==0.4.6 tenacity==6.2.0 diff --git a/tests/test_elements_worker.py b/tests/test_elements_worker.py index 0794f89c..17519bba 100644 --- a/tests/test_elements_worker.py +++ b/tests/test_elements_worker.py @@ -243,12 +243,19 @@ def test_load_corpus_classes_api_error(responses, mock_elements_worker): ) assert not mock_elements_worker.classes - with pytest.raises(ErrorResponse): + with pytest.raises( + Exception, match="Stopping pagination as data will be incomplete" + ): mock_elements_worker.load_corpus_classes(corpus_id) - assert len(responses.calls) == 2 + assert len(responses.calls) == 6 assert [call.request.url for call in responses.calls] == [ "http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/", + # We do 5 retries + f"http://testserver/api/v1/corpus/{corpus_id}/classes/?page=1", + f"http://testserver/api/v1/corpus/{corpus_id}/classes/?page=1", + f"http://testserver/api/v1/corpus/{corpus_id}/classes/?page=1", + f"http://testserver/api/v1/corpus/{corpus_id}/classes/?page=1", f"http://testserver/api/v1/corpus/{corpus_id}/classes/?page=1", ] assert not mock_elements_worker.classes @@ -261,6 +268,7 @@ def test_load_corpus_classes(responses, mock_elements_worker): f"http://testserver/api/v1/corpus/{corpus_id}/classes/", status=200, json={ + "count": 3, "results": [ { "id": "0000", @@ -277,7 +285,7 @@ def test_load_corpus_classes(responses, mock_elements_worker): "name": "bad", "nb_best": 0, }, - ] + ], }, ) @@ -305,13 +313,14 @@ def test_get_ml_class_id_load_classes(responses, mock_elements_worker): f"http://testserver/api/v1/corpus/{corpus_id}/classes/", status=200, json={ + "count": 1, "results": [ { "id": "0000", "name": "good", "nb_best": 0, } - ] + ], }, ) @@ -378,12 +387,13 @@ def test_get_ml_class_reload(responses, mock_elements_worker): responses.GET, f"http://testserver/api/v1/corpus/{corpus_id}/classes/", json={ + "count": 1, "results": [ { "id": "class1_id", "name": "class1", } - ] + ], }, ) @@ -400,6 +410,7 @@ def test_get_ml_class_reload(responses, mock_elements_worker): responses.GET, f"http://testserver/api/v1/corpus/{corpus_id}/classes/", json={ + "count": 2, "results": [ { "id": "class1_id", @@ -409,7 +420,7 @@ def test_get_ml_class_reload(responses, mock_elements_worker): "id": "class2_id", "name": "class2", }, - ] + ], }, ) -- GitLab