Skip to content

Commit

Permalink
Replace dict() and json() with model_dump() and model_dump_json(), re…
Browse files Browse the repository at this point in the history
…spectively to avoid deprecation warnings.
  • Loading branch information
Ghulam Mustafa Majal committed Sep 23, 2024
1 parent a357dd0 commit 979a4bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tests/interface/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)


Expand Down

0 comments on commit 979a4bb

Please sign in to comment.