Skip to content

Commit

Permalink
Added new test case for bulk delete with single item
Browse files Browse the repository at this point in the history
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
  • Loading branch information
Harshil-Jani committed Dec 23, 2024
1 parent 4091816 commit b305e58
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test_opensearchpy/test_server/test_helpers/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,26 @@ def streaming_bulk() -> Any:


class TestBulk(OpenSearchTestCase):
def test_bulk_delete_with_single_item(self) -> None:
docs = [{"answer": 42, "_id": 1}]
success, failed = helpers.bulk(
self.client, docs, index="test-index", refresh=True
)

self.assertEqual(1, success)
self.assertFalse(failed)
self.assertEqual(1, self.client.count(index="test-index")["count"])
self.assertEqual(
{"answer": 42}, self.client.get(index="test-index", id=1)["_source"]
)

docs = [{"delete": {"_index": "test-index", "_id": 1}}]
success, failed = helpers.bulk(self.client, docs)
self.assertEqual(1,success)
self.assertFalse(failed)
self.assertEqual(0, self.client.count(index="test-index")["count"])


def test_bulk_works_with_single_item(self) -> None:
docs = [{"answer": 42, "_id": 1}]
success, failed = helpers.bulk(
Expand Down

0 comments on commit b305e58

Please sign in to comment.