Skip to content

Commit 1378073

Browse files
committed
Moved helpers unit tests to test_helpers
1 parent 12c2a46 commit 1378073

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

test_elasticsearch/test_helpers.py

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import threading
44

55
from elasticsearch import helpers, Elasticsearch
6+
from elasticsearch.serializer import JSONSerializer
67

78
from .test_cases import TestCase
89

@@ -25,3 +26,13 @@ def test_chunk_sent_from_different_threads(self, _process_bulk_chunk):
2526

2627
self.assertTrue(len(set([r[1] for r in results])) > 1)
2728

29+
class TestChunkActions(TestCase):
30+
def setUp(self):
31+
super(TestChunkActions, self).setUp()
32+
self.actions = [({'index': {}}, {'some': 'data', 'i': i}) for i in range(100)]
33+
34+
def test_chunks_are_chopped_by_byte_size(self):
35+
self.assertEquals(100, len(list(helpers._chunk_actions(self.actions, 100000, 1, JSONSerializer()))))
36+
37+
def test_chunks_are_chopped_by_chunk_size(self):
38+
self.assertEquals(10, len(list(helpers._chunk_actions(self.actions, 10, 99999999, JSONSerializer()))))

test_elasticsearch/test_server/test_helpers.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
from elasticsearch import helpers, TransportError
2-
from elasticsearch.serializer import JSONSerializer
32

43
from . import ElasticsearchTestCase
5-
from ..test_cases import SkipTest, TestCase
6-
7-
8-
class TestChunkActions(TestCase):
9-
def setUp(self):
10-
super(TestChunkActions, self).setUp()
11-
self.actions = [({'index': {}}, {'some': 'data', 'i': i}) for i in range(100)]
12-
13-
def test_chunks_are_chopped_by_byte_size(self):
14-
self.assertEquals(100, len(list(helpers._chunk_actions(self.actions, 100000, 1, JSONSerializer()))))
15-
16-
def test_chunks_are_chopped_by_chunk_size(self):
17-
self.assertEquals(10, len(list(helpers._chunk_actions(self.actions, 10, 99999999, JSONSerializer()))))
4+
from ..test_cases import SkipTest
185

196

207
class FailingBulkClient(object):

0 commit comments

Comments
 (0)