Restructuring helpers dir (#886)

* PEP8 formatting & package structuring

* adding internal function imports into helpers init

* changed absolute paths for mock

* removed debugging print statements

* resolving @fxdgear 's comment
This commit is contained in:
Asher Mancinelli
2019-01-14 11:27:02 -08:00
committed by Nick Lang
parent 3c8cfa17fe
commit 85573db275
4 changed files with 482 additions and 458 deletions
+2 -3
View File
@@ -26,7 +26,7 @@ mock_process_bulk_chunk.call_count = 0
class TestParallelBulk(TestCase):
@mock.patch('elasticsearch.helpers._process_bulk_chunk', side_effect=mock_process_bulk_chunk)
@mock.patch('elasticsearch.helpers.actions._process_bulk_chunk', side_effect=mock_process_bulk_chunk)
def test_all_chunks_sent(self, _process_bulk_chunk):
actions = ({'x': i} for i in range(100))
list(helpers.parallel_bulk(Elasticsearch(), actions, chunk_size=2))
@@ -34,14 +34,13 @@ class TestParallelBulk(TestCase):
self.assertEquals(50, _process_bulk_chunk.call_count)
@mock.patch(
'elasticsearch.helpers._process_bulk_chunk',
'elasticsearch.helpers.actions._process_bulk_chunk',
# make sure we spend some time in the thread
side_effect=lambda *a: [(True, time.sleep(.001) or threading.current_thread().ident)]
)
def test_chunk_sent_from_different_threads(self, _process_bulk_chunk):
actions = ({'x': i} for i in range(100))
results = list(helpers.parallel_bulk(Elasticsearch(), actions, thread_count=10, chunk_size=2))
self.assertTrue(len(set([r[1] for r in results])) > 1)
class TestChunkActions(TestCase):