From 9d415fadef381565c68ab502df5c08b961622e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Sun, 11 Oct 2015 05:00:14 +0200 Subject: [PATCH] Adding tests for indexing strings via bulk helpers --- elasticsearch/helpers/__init__.py | 2 +- test_elasticsearch/test_helpers.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/elasticsearch/helpers/__init__.py b/elasticsearch/helpers/__init__.py index e91f92db..6cde46b4 100644 --- a/elasticsearch/helpers/__init__.py +++ b/elasticsearch/helpers/__init__.py @@ -27,7 +27,7 @@ def expand_action(data): """ # when given a string, assume user wants to index raw json if isinstance(data, string_types): - return '{"index": {}}', data + return '{"index":{}}', data # make sure we don't alter the action data = data.copy() diff --git a/test_elasticsearch/test_helpers.py b/test_elasticsearch/test_helpers.py index 24f2073b..53996974 100644 --- a/test_elasticsearch/test_helpers.py +++ b/test_elasticsearch/test_helpers.py @@ -36,3 +36,7 @@ class TestChunkActions(TestCase): def test_chunks_are_chopped_by_chunk_size(self): self.assertEquals(10, len(list(helpers._chunk_actions(self.actions, 10, 99999999, JSONSerializer())))) + +class TestExpandActions(TestCase): + def test_string_actions_are_marked_as_simple_inserts(self): + self.assertEquals(('{"index":{}}', "whatever"), helpers.expand_action('whatever'))