def test_read_bulks_and_assume_no_metadata(self): data = [ '{"key": "value1"}', '{"key": "value2"}', '{"key": "value3"}', '{"key": "value4"}', '{"key": "value5"}', '{"key": "value6"}', '{"key": "value7"}' ] bulk_size = 3 source = params.Slice(io.StringAsFileSource, 0, len(data)) am_handler = params.NoneActionMetaData() reader = params.IndexDataReader(data, batch_size=bulk_size, bulk_size=bulk_size, file_source=source, action_metadata=am_handler, index_name="test_index", type_name="test_type") # no meta-data, hence line numbers and bulk sizes need to be identical expected_bulk_sizes = [3, 3, 1] self.assert_bulks_sized(reader, expected_bulk_sizes, expected_bulk_sizes)
def test_read_bulks_and_assume_no_metadata(self): data = [ '{"key": "value1"}', '{"key": "value2"}', '{"key": "value3"}', '{"key": "value4"}', '{"key": "value5"}', '{"key": "value6"}', '{"key": "value7"}' ] bulk_size = 3 source = params.Slice(io.StringAsFileSource, 0, len(data)) am_handler = params.NoneActionMetaData() reader = params.IndexDataReader(data, batch_size=bulk_size, bulk_size=bulk_size, file_source=source, action_metadata=am_handler, index_name="test_index", type_name="test_type") # always double the amount as one line contains the data and one line contains the index command expected_bulk_sizes = [3, 3, 1] self.assert_bulks_sized(reader, expected_bulk_sizes)
def test_none_action_meta_data_is_none(self): self.assertIsNone(next(params.NoneActionMetaData()))