Skip to content

Commit 5e6feaf

Browse files
committed
Adapt the tests for csv delimiter
1 parent e53b5f7 commit 5e6feaf

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed
File renamed without changes.

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def songs_csv():
7777

7878

7979
@fixture(scope="session")
80-
def songs_csv_delimiter():
80+
def songs_csv_custom_separator():
8181
"""
82-
Runs once per session. Provides the content of songs_delimiter.csv from read..
82+
Runs once per session. Provides the content of songs_custom_delimiter.csv from read..
8383
"""
84-
with open("./datasets/songs_delimiter.csv", encoding="utf-8") as song_csv_file:
84+
with open("./datasets/songs_custom_delimiter.csv", encoding="utf-8") as song_csv_file:
8585
return song_csv_file.read().encode("utf-8")
8686

8787

tests/index/test_index_document_meilisearch.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,18 @@ def test_add_documents_csv(empty_index, songs_csv):
197197
assert index.get_primary_key() == "id"
198198

199199

200-
def test_add_documents_csv_with_delimiter(empty_index, songs_csv_delimiter):
200+
def test_add_documents_csv_with_delimiter(empty_index, songs_csv_custom_separator):
201201
"""Tests adding new documents to a clean index."""
202202
index = empty_index("csv-delimiter")
203-
response = index.add_documents_csv(songs_csv_delimiter, csv_delimiter=";")
203+
response = index.add_documents_csv(songs_csv_custom_separator, csv_delimiter=";")
204204
assert isinstance(response, TaskInfo)
205205
assert response.task_uid is not None
206206
task = index.wait_for_task(response.task_uid)
207207
assert task.status == "succeeded"
208+
assert task.details["receivedDocuments"] == 53
209+
documents = index.get_documents().results
210+
assert documents[1].country == "Europe"
211+
assert documents[4].artist == "Elton John"
208212

209213

210214
def test_update_documents_csv(index_with_documents, songs_csv):
@@ -218,14 +222,18 @@ def test_update_documents_csv(index_with_documents, songs_csv):
218222
assert index.get_primary_key() == "id"
219223

220224

221-
def test_update_documents_csv_with_delimiter(index_with_documents, songs_csv_delimiter):
225+
def test_update_documents_csv_with_delimiter(index_with_documents, songs_csv_custom_separator):
222226
"""Tests adding new documents to a clean index."""
223-
index = index_with_documents("csv-delimiter")
224-
response = index.update_documents_csv(songs_csv_delimiter, csv_delimiter=";")
227+
index = index_with_documents()
228+
response = index.update_documents_csv(songs_csv_custom_separator, csv_delimiter=";")
225229
assert isinstance(response, TaskInfo)
226230
assert response.task_uid is not None
227231
task = index.wait_for_task(response.task_uid)
228232
assert task.status == "succeeded"
233+
assert task.details["receivedDocuments"] == 53
234+
document = index.get_document("813645611")
235+
assert document.country == "Europe"
236+
assert document.artist == "Elton John"
229237

230238

231239
def test_add_documents_json(empty_index, small_movies_json_file):

0 commit comments

Comments
 (0)