From 979a4bbbd4beb3db60c5b8821c0f3fad525a322a Mon Sep 17 00:00:00 2001 From: Ghulam Mustafa Majal Date: Mon, 23 Sep 2024 14:33:11 +0200 Subject: [PATCH] Replace dict() and json() with model_dump() and model_dump_json(), respectively to avoid deprecation warnings. --- tests/interface/test_rest.py | 6 +++--- tests/test_integration.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/interface/test_rest.py b/tests/interface/test_rest.py index 8a82242..649ba0d 100644 --- a/tests/interface/test_rest.py +++ b/tests/interface/test_rest.py @@ -65,12 +65,12 @@ def documents(train_data): def test_return_http_200_for_predict(client, documents): - resp = client.post(PREDICT_ENDPOINT, json=documents.dict()) + resp = client.post(PREDICT_ENDPOINT, json=documents.model_dump()) assert resp.status_code == status.HTTP_200_OK def test_return_scores_for_predict(client, documents): - resp = client.post(PREDICT_ENDPOINT, json=documents.dict()) + resp = client.post(PREDICT_ENDPOINT, json=documents.model_dump()) expected_scores = QualityEstimation( scores=[ @@ -79,7 +79,7 @@ def test_return_scores_for_predict(client, documents): ) ] ) - assert resp.json() == json.loads(expected_scores.json()) + assert resp.json() == json.loads(expected_scores.model_dump_json()) def test_return_http_200_for_up(client): diff --git a/tests/test_integration.py b/tests/test_integration.py index ba1f0e9..2b6ddca 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -92,13 +92,13 @@ def test_rest(train_data_file, model_path): scores=[0.5, 1], ) ] - ).dict(), + ).model_dump(), ) assert res.status_code == status.HTTP_200_OK # We can make following assumption due to the construction of train data assert res.json() == json.loads( - QualityEstimation(scores=[QualityScores(name=Metric.RECALL, scores=[1])]).json() + QualityEstimation(scores=[QualityScores(name=Metric.RECALL, scores=[1])]).model_dump_json() )