Skip to content

Commit 654acd1

Browse files
authored
Fix test_bulk_works_with_bytestring_body (#46)
1 parent 1b337ed commit 654acd1

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

test_elasticsearch_serverless/test_async/test_server/test_clients.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ async def test_bulk_works_with_bytestring_body(async_client):
5151
docs = (
5252
b'{ "index" : { "_index" : "bulk_test_index", "_id" : "2" } }\n{"answer": 42}'
5353
)
54-
response = await async_client.bulk(body=docs)
54+
resp = await async_client.bulk(body=docs)
5555

56-
assert response["errors"] is False
57-
assert len(response["items"]) == 1
56+
assert resp["errors"] is False
57+
assert len(resp["items"]) == 1
58+
59+
# Pop inconsistent items before asserting
60+
resp["items"][0]["index"].pop("_id")
61+
resp["items"][0]["index"].pop("_version")
62+
resp["items"][0]["index"].pop("_shards")
63+
assert resp["items"][0] == {
64+
"index": {
65+
"_index": "bulk_test_index",
66+
"result": "created",
67+
"_seq_no": 0,
68+
"_primary_term": 1,
69+
"status": 201,
70+
}
71+
}

test_elasticsearch_serverless/test_server/test_clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def test_bulk_works_with_bytestring_body(sync_client):
5555
# Pop inconsistent items before asserting
5656
resp["items"][0]["index"].pop("_id")
5757
resp["items"][0]["index"].pop("_version")
58+
resp["items"][0]["index"].pop("_shards")
5859
assert resp["items"][0] == {
5960
"index": {
6061
"_index": "bulk_test_index",
6162
"result": "created",
62-
"_shards": {"total": 2, "successful": 1, "failed": 0},
6363
"_seq_no": 0,
6464
"_primary_term": 1,
6565
"status": 201,

0 commit comments

Comments
 (0)