From 4cdf81e74142ddd2f501518b54ecb9591fbd873a Mon Sep 17 00:00:00 2001 From: Harshil Jani Date: Sun, 29 Dec 2024 18:27:01 +0530 Subject: [PATCH] Added new test case for bulk delete with single item (#878) Signed-off-by: Harshil Jani --- test_opensearchpy/test_server/test_clients.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test_opensearchpy/test_server/test_clients.py b/test_opensearchpy/test_server/test_clients.py index 2363847b..b11ee27a 100644 --- a/test_opensearchpy/test_server/test_clients.py +++ b/test_opensearchpy/test_server/test_clients.py @@ -110,6 +110,18 @@ def test_bulk_works_with_bytestring_body(self) -> None: self.assertFalse(response["errors"]) self.assertEqual(1, len(response["items"])) + def test_bulk_works_with_delete(self) -> None: + docs = '{ "index" : { "_index" : "bulk_test_index", "_id" : "1" } }\n{"answer": 42}\n{ "delete" : { "_index" : "bulk_test_index", "_id": "1" } }' + response = self.client.bulk(body=docs) + + self.assertFalse(response["errors"]) + self.assertEqual(2, len(response["items"])) + + # Check insertion status + self.assertEqual(201, response["items"][0]["index"]["status"]) + # Check deletion status + self.assertEqual(200, response["items"][1]["delete"]["status"]) + class TestClose(OpenSearchTestCase): def test_close_doesnt_break_client(self) -> None: