def test_create_es_action_with_more_than_one_routing_field_in_translation_map( self): create_es_actions( 'baz', [{ 'id': '321' }], TranslationMap({ 'route1': { 'routing_field': True }, 'route2': { 'routing_field': True } }))
def test_create_es_action_without_id_field_in_translation_map(self): self.assertEqual( '{"index": {"_index": "baz", "_type": "doc", "_id": "123"}}\n{"id": "123", "foo": "bar"}', create_es_actions('baz', [{ 'id': '123', 'foo': 'bar' }], TranslationMap()))
def test_create_es_action_with_multivalued_and_named_field(self): self.assertEqual( [({ 'index': { '_index': 'baz', '_type': 'doc', '_id': '808' } }, { 'id': '808', 'path': 'value_01' }), ({ 'index': { '_index': 'baz', '_type': 'doc', '_id': hashlib.sha256(b'value_02').hexdigest() } }, { 'path': 'value_02', 'documentId': '808', 'type': 'Duplicate' })], create_es_actions( 'baz', [{ 'id': '808', 'my_field': ['value_01', 'value_02'] }], TranslationMap( {'my_field': { 'multivalued': False, 'name': 'path' }})))
def test_create_es_action_with_nonexistent_routing_field(self): self.assertEqual( '{"index": {"_index": "baz", "_type": "doc", "_id": "808"}}\n{"id": "808"}', create_es_actions( 'baz', [{ 'id': '808' }], TranslationMap({'root_id': { 'routing_field': True }})))
def test_create_es_actions(self): self.assertEqual( '{"index": {"_index": "baz", "_type": "doc", "_id": "123"}}\n{"my_id": "123", "foo": "bar"}', create_es_actions('baz', [{ 'my_id': '123', 'foo': 'bar' }], TranslationMap({'my_id': { 'name': '_id' }})))
def test_create_es_action_with_routing_field_false(self): self.assertEqual( '{"index": {"_index": "baz", "_type": "doc", "_id": "808"}}\n{"id": "808", "root_id": "654"}', create_es_actions( 'baz', [{ 'id': '808', 'root_id': '654' }], TranslationMap({'root_id': { 'routing_field': False }})))
def test_create_es_action_with_routing_field_in_translation_map(self): self.assertEqual( '{"index": {"_index": "baz", "_type": "doc", "_id": "321", "_routing": "456"}}\n{"id": "321", "root_id": "456"}', create_es_actions( 'baz', [{ 'id': '321', 'root_id': '456' }], TranslationMap({'root_id': { 'routing_field': True }})))
def test_create_es_action_without_id_field_in_translation_map(self): self.assertEqual([({ 'index': { '_index': 'baz', '_type': 'doc', '_id': '123' } }, { 'id': '123', 'foo': 'bar' })], create_es_actions('baz', [{ 'id': '123', 'foo': 'bar' }], TranslationMap()))
def test_create_es_action_with_nonexistent_routing_field(self): self.assertEqual([({ 'index': { '_index': 'baz', '_type': 'doc', '_id': '808' } }, { 'id': '808' })], create_es_actions( 'baz', [{ 'id': '808' }], TranslationMap( {'root_id': { 'routing_field': True }})))
def test_create_es_actions(self): self.assertEqual([({ 'index': { '_index': 'baz', '_type': 'doc', '_id': '123' } }, { 'my_id': '123', 'foo': 'bar' })], create_es_actions( 'baz', [{ 'my_id': '123', 'foo': 'bar' }], TranslationMap({'my_id': { 'name': '_id' }})))
def test_create_es_action_with_routing_field_false(self): self.assertEqual([({ 'index': { '_index': 'baz', '_type': 'doc', '_id': '808' } }, { 'id': '808', 'root_id': '654' })], create_es_actions( 'baz', [{ 'id': '808', 'root_id': '654' }], TranslationMap( {'root_id': { 'routing_field': False }})))
def test_create_es_action_with_routing_field_in_translation_map(self): self.assertEqual([({ 'index': { '_index': 'baz', '_type': 'doc', '_id': '321', '_routing': '456' } }, { 'id': '321', 'root_id': '456' })], create_es_actions( 'baz', [{ 'id': '321', 'root_id': '456' }], TranslationMap( {'root_id': { 'routing_field': True }})))