desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Test if status fetch fails with CommandExecutionError'
| def test_info_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def info(self):
'\n Mock of info method\n '
raise TransportError('custom error', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.info)
|
'Test if node status fetch succeeds'
| def test_node_info(self):
| class MockElasticNodes(object, ):
'\n Mock of Elasticsearch NodesClient\n '
def info(self, node_id=None, flat_settings=None):
'\n Mock of info method\n '
return [{'test': 'key'}]
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
nodes = MockElasticNodes()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertListEqual(elasticsearch.node_info(), [{'test': 'key'}])
|
'Test if node status fetch fails with CommandExecutionError'
| def test_node_info_failure(self):
| class MockElasticNodes(object, ):
'\n Mock of Elasticsearch NodesClient\n '
def info(self, node_id=None, flat_settings=None):
'\n Mock of info method\n '
raise TransportError('custom error', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
nodes = MockElasticNodes()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.node_info)
|
'Test if cluster status health fetch succeeds'
| def test_cluster_health(self):
| class MockElasticCluster(object, ):
'\n Mock of Elasticsearch ClusterClient\n '
def health(self, index=None, level=None, local=None):
'\n Mock of health method\n '
return [{'test': 'key'}]
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
cluster = MockElasticCluster()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertListEqual(elasticsearch.cluster_health(), [{'test': 'key'}])
|
'Test if cluster status health fetch fails with CommandExecutionError'
| def test_cluster_health_failure(self):
| class MockElasticCluster(object, ):
'\n Mock of Elasticsearch ClusterClient\n '
def health(self, index=None, level=None, local=None):
'\n Mock of health method\n '
raise TransportError('custom error', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
cluster = MockElasticCluster()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.cluster_health)
|
'Test if cluster stats fetch succeeds'
| def test_cluster_stats(self):
| class MockElasticCluster(object, ):
'\n Mock of Elasticsearch ClusterClient\n '
def stats(self, node_id=None):
'\n Mock of health method\n '
return [{'test': 'key'}]
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
cluster = MockElasticCluster()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertListEqual(elasticsearch.cluster_stats(), [{'test': 'key'}])
|
'Test if cluster stats fetch fails with CommandExecutionError'
| def test_cluster_stats_failure(self):
| class MockElasticCluster(object, ):
'\n Mock of Elasticsearch ClusterClient\n '
def stats(self, node_id=None):
'\n Mock of health method\n '
raise TransportError('custom error', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
cluster = MockElasticCluster()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.cluster_stats)
|
'Test if alias is created'
| def test_alias_create(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_alias(self, index=None, name=None, body=None):
'\n Mock of put_alias method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.alias_create('foo', 'bar', body='baz'))
|
'Test if alias creation is not acked'
| def test_alias_create_unack(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_alias(self, index=None, name=None, body=None):
'\n Mock of put_alias method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.alias_create('foo', 'bar', body='baz'))
|
'Test if alias creation fails with CommandExecutionError'
| def test_alias_create_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_alias(self, index=None, name=None, body=None):
'\n Mock of put_alias method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.alias_create, 'foo', 'bar', body='baz')
|
'Test if alias is deleted'
| def test_alias_delete(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_alias(self, index=None, name=None):
'\n Mock of delete_alias method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.alias_delete('foo', 'bar'))
|
'Test if alias deletion is not acked'
| def test_alias_delete_unack(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_alias(self, index=None, name=None):
'\n Mock of delete_alias method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.alias_delete('foo', 'bar'))
|
'Test if alias deletion fails with CommandExecutionError'
| def test_alias_delete_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_alias(self, index=None, name=None):
'\n Mock of delete_alias method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.alias_delete, 'foo', 'bar')
|
'Test if alias exists'
| def test_alias_exists(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists_alias(self, index=None, name=None):
'\n Mock of exists_alias method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.alias_exists('foo', 'bar'))
|
'Test if alias doesn\'t exist'
| def test_alias_exists_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists_alias(self, index=None, name=None):
'\n Mock of exists_alias method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.alias_exists('foo', 'bar'))
|
'Test if alias status obtain fails with CommandExecutionError'
| def test_alias_exists_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists_alias(self, index=None, name=None):
'\n Mock of exists_alias method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.alias_exists, 'foo', 'bar')
|
'Test if alias can be obtained'
| def test_alias_get(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_alias(self, index=None, name=None):
'\n Mock of get_alias method\n '
return {'test': 'key'}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.alias_get('foo', 'bar'), {'test': 'key'})
|
'Test if alias doesn\'t exist'
| def test_alias_get_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_alias(self, index=None, name=None):
'\n Mock of get_alias method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.alias_get('foo', 'bar'), None)
|
'Test if alias obtain fails with CommandExecutionError'
| def test_alias_get_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_alias(self, index=None, name=None):
'\n Mock of get_alias method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.alias_get, 'foo', 'bar')
|
'Test if document can be created'
| def test_document_create(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def index(self, index=None, doc_type=None, body=None, id=None):
'\n Mock of index method\n '
return {'test': 'key'}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.document_create('foo', 'bar'), {'test': 'key'})
|
'Test if document creation fails with CommandExecutionError'
| def test_document_create_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def index(self, index=None, doc_type=None, body=None, id=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.document_create, 'foo', 'bar')
|
'Test if document can be deleted'
| def test_document_delete(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def delete(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
return {'test': 'key'}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.document_delete('foo', 'bar', 'baz'), {'test': 'key'})
|
'Test if document deletion fails with CommandExecutionError'
| def test_document_delete_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def delete(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.document_delete, 'foo', 'bar', 'baz')
|
'Test if document status can be obtained'
| def test_document_exists(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def exists(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
return True
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.document_exists('foo', 'bar'))
|
'Test if document doesn\'t exist'
| def test_document_exists_not(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def exists(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
return False
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.document_exists('foo', 'bar'))
|
'Test if document exist state fails with CommandExecutionError'
| def test_document_exists_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def exists(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.document_exists, 'foo', 'bar')
|
'Test if document exists'
| def test_document_get(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def get(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
return {'test': 'key'}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.document_get('foo', 'bar'), {'test': 'key'})
|
'Test if document doesn\'t exit'
| def test_document_get_not(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def get(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
raise NotFoundError
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.document_get('foo', 'bar'), None)
|
'Test if document obtain fails with CommandExecutionError'
| def test_document_get_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def get(self, index=None, doc_type=None, id=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.document_get, 'foo', 'bar')
|
'Test if index can be created'
| def test_index_create(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def create(self, index=None, body=None):
'\n Mock of index method\n '
return {'acknowledged': True, 'shards_acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_create('foo', 'bar'))
|
'Test if index is created and no shards info is returned'
| def test_index_create_no_shards(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def create(self, index=None, body=None):
'\n Mock of index method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_create('foo', 'bar'))
|
'Test if index is created and shards didn\'t acked'
| def test_index_create_not_shards(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def create(self, index=None, body=None):
'\n Mock of index method\n '
return {'acknowledged': True, 'shards_acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_create('foo', 'bar'))
|
'Test if index is created and shards didn\'t acked'
| def test_index_create_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def create(self, index=None, body=None):
'\n Mock of index method\n '
return {'acknowledged': False, 'shards_acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_create('foo', 'bar'))
|
'Test if index creation fails with CommandExecutionError'
| def test_index_create_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def create(self, index=None, body=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_create, 'foo', 'bar')
|
'Test if index can be deleted'
| def test_index_delete(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete(self, index=None):
'\n Mock of index method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_delete('foo', 'bar'))
|
'Test if index is deleted and shards didn\'t acked'
| def test_index_delete_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete(self, index=None):
'\n Mock of index method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_delete('foo', 'bar'))
|
'Test if index deletion fails with CommandExecutionError'
| def test_index_delete_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete(self, index=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_delete, 'foo', 'bar')
|
'Test if index exists'
| def test_index_exists(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists(self, index=None):
'\n Mock of index method\n '
return True
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_exists('foo', 'bar'))
|
'Test if index doesn\'t exist'
| def test_index_exists_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists(self, index=None):
'\n Mock of index method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_exists('foo', 'bar'))
|
'Test if alias exist state fails with CommandExecutionError'
| def test_index_exists_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists(self, index=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_exists, 'foo', 'bar')
|
'Test if index can be obtained'
| def test_index_get(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get(self, index=None):
'\n Mock of index method\n '
return {'test': 'key'}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.index_get('foo', 'bar'), {'test': 'key'})
|
'Test if index doesn\'t exist'
| def test_index_get_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get(self, index=None):
'\n Mock of index method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.index_get('foo', 'bar'), None)
|
'Test if index obtain fails with CommandExecutionError'
| def test_index_get_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get(self, index=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_get, 'foo', 'bar')
|
'Test if index can be opened'
| def test_index_open(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def open(self, index=None, allow_no_indices=None, expand_wildcards=None, ignore_unavailable=None):
'\n Mock of index method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_open('foo', 'bar'))
|
'Test if index open isn\'t acked'
| def test_index_open_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def open(self, index=None, allow_no_indices=None, expand_wildcards=None, ignore_unavailable=None):
'\n Mock of index method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_open('foo', 'bar'))
|
'Test if alias opening fails with CommandExecutionError'
| def test_index_open_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def open(self, index=None, allow_no_indices=None, expand_wildcards=None, ignore_unavailable=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_open, 'foo', 'bar')
|
'Test if index can be closed'
| def test_index_close(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def close(self, index=None, allow_no_indices=None, expand_wildcards=None, ignore_unavailable=None):
'\n Mock of index method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_close('foo', 'bar'))
|
'Test if index close isn\'t acked'
| def test_index_close_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def close(self, index=None, allow_no_indices=None, expand_wildcards=None, ignore_unavailable=None):
'\n Mock of index method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_close('foo', 'bar'))
|
'Test if index closing fails with CommandExecutionError'
| def test_index_close_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def close(self, index=None, allow_no_indices=None, expand_wildcards=None, ignore_unavailable=None):
'\n Mock of index method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_close, 'foo', 'bar')
|
'Test if mapping can be created'
| def test_mapping_create(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_mapping(self, index=None, doc_type=None, body=None):
'\n Mock of put_mapping method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.mapping_create('foo', 'bar', 'baz'))
|
'Test if mapping creation didn\'t ack'
| def test_mapping_create_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_mapping(self, index=None, doc_type=None, body=None):
'\n Mock of put_mapping method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.mapping_create('foo', 'bar', 'baz'))
|
'Test if mapping creation fails'
| def test_mapping_create_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_mapping(self, index=None, doc_type=None, body=None):
'\n Mock of put_mapping method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.mapping_create, 'foo', 'bar', 'baz')
|
'Test if mapping can be created'
| def test_mapping_delete(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_mapping(self, index=None, doc_type=None):
'\n Mock of put_mapping method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.mapping_delete('foo', 'bar', 'baz'))
|
'Test if mapping creation didn\'t ack'
| def test_mapping_delete_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_mapping(self, index=None, doc_type=None):
'\n Mock of put_mapping method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.mapping_delete('foo', 'bar', 'baz'))
|
'Test if mapping creation fails'
| def test_mapping_delete_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_mapping(self, index=None, doc_type=None):
'\n Mock of put_mapping method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.mapping_delete, 'foo', 'bar', 'baz')
|
'Test if mapping can be created'
| def test_mapping_get(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_mapping(self, index=None, doc_type=None):
'\n Mock of get_mapping method\n '
return {'test': 'key'}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.mapping_get('foo', 'bar', 'baz'), {'test': 'key'})
|
'Test if mapping creation didn\'t ack'
| def test_mapping_get_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_mapping(self, index=None, doc_type=None):
'\n Mock of get_mapping method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.mapping_get('foo', 'bar', 'baz'), None)
|
'Test if mapping creation fails'
| def test_mapping_get_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_mapping(self, index=None, doc_type=None):
'\n Mock of get_mapping method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.mapping_get, 'foo', 'bar', 'baz')
|
'Test if mapping can be created'
| def test_index_template_create(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_template(self, name=None, body=None):
'\n Mock of put_template method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_template_create('foo', 'bar'))
|
'Test if mapping creation didn\'t ack'
| def test_index_template_create_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_template(self, name=None, body=None):
'\n Mock of put_template method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_template_create('foo', 'bar'))
|
'Test if mapping creation fails'
| def test_index_template_create_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_template(self, name=None, body=None):
'\n Mock of put_template method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_template_create, 'foo', 'bar')
|
'Test if mapping can be created'
| def test_index_template_delete(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_template(self, name=None):
'\n Mock of delete_template method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_template_delete('foo'))
|
'Test if mapping creation didn\'t ack'
| def test_index_template_delete_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_template(self, name=None):
'\n Mock of delete_template method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_template_delete('foo'))
|
'Test if mapping creation fails'
| def test_index_template_delete_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_template(self, name=None):
'\n Mock of delete_template method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_template_delete, 'foo')
|
'Test if mapping can be created'
| def test_index_template_exists(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists_template(self, name=None):
'\n Mock of exists_template method\n '
return True
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.index_template_exists('foo'))
|
'Test if mapping creation didn\'t ack'
| def test_index_template_exists_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists_template(self, name=None):
'\n Mock of exists_template method\n '
return False
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.index_template_exists('foo'))
|
'Test if mapping creation fails'
| def test_index_template_exists_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def exists_template(self, name=None):
'\n Mock of exists_template method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_template_exists, 'foo')
|
'Test if mapping can be created'
| def test_index_template_get(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_template(self, name=None):
'\n Mock of get_template method\n '
return {'test': 'key'}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.index_template_get('foo'), {'test': 'key'})
|
'Test if mapping creation didn\'t ack'
| def test_index_template_get_not(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_template(self, name=None):
'\n Mock of get_template method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.index_template_get('foo'), None)
|
'Test if mapping creation fails'
| def test_index_template_get_failure(self):
| class MockElasticIndices(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_template(self, name=None):
'\n Mock of get_template method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
indices = MockElasticIndices()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.index_template_get, 'foo')
|
'Test if mapping can be created'
| def test_pipeline_get(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_pipeline(self, id=None):
'\n Mock of get_pipeline method\n '
return {'test': 'key'}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.pipeline_get('foo'), {'test': 'key'})
|
'Test if mapping creation didn\'t ack'
| def test_pipeline_get_not(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_pipeline(self, id=None):
'\n Mock of get_pipeline method\n '
raise NotFoundError
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.pipeline_get('foo'), None)
|
'Test if mapping creation fails'
| def test_pipeline_get_failure(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def get_pipeline(self, id=None):
'\n Mock of get_pipeline method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_get, 'foo')
|
'Test if mapping creation fails with CEE on invalid elasticsearch-py version'
| def test_pipeline_get_wrong_version(self):
| class MockElasticIngest(object, ):
pass
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_get, 'foo')
|
'Test if mapping can be created'
| def test_pipeline_delete(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_pipeline(self, id=None):
'\n Mock of delete_pipeline method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.pipeline_delete('foo'))
|
'Test if mapping creation didn\'t ack'
| def test_pipeline_delete_not(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_pipeline(self, id=None):
'\n Mock of delete_pipeline method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.pipeline_delete('foo'))
|
'Test if mapping creation fails'
| def test_pipeline_delete_failure(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def delete_pipeline(self, id=None):
'\n Mock of delete_pipeline method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_delete, 'foo')
|
'Test if mapping creation fails with CEE on invalid elasticsearch-py version'
| def test_pipeline_delete_wrong_version(self):
| class MockElasticIngest(object, ):
pass
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_delete, 'foo')
|
'Test if mapping can be created'
| def test_pipeline_create(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_pipeline(self, id=None, body=None):
'\n Mock of put_pipeline method\n '
return {'acknowledged': True}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.pipeline_create('foo', 'bar'))
|
'Test if mapping creation didn\'t ack'
| def test_pipeline_create_not(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_pipeline(self, id=None, body=None):
'\n Mock of put_pipeline method\n '
return {'acknowledged': False}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.pipeline_create('foo', 'bar'))
|
'Test if mapping creation fails'
| def test_pipeline_create_failure(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def put_pipeline(self, id=None, body=None):
'\n Mock of put_pipeline method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_create, 'foo', 'bar')
|
'Test if mapping creation fails with CEE on invalid elasticsearch-py version'
| def test_pipeline_create_wrong_version(self):
| class MockElasticIngest(object, ):
pass
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_create, 'foo', 'bar')
|
'Test if mapping can be created'
| def test_pipeline_simulate(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def simulate(self, id=None, body=None, verbose=None):
'\n Mock of simulate method\n '
return {'test': 'key'}
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.pipeline_simulate('foo', 'bar'), {'test': 'key'})
|
'Test if mapping creation fails'
| def test_pipeline_simulate_failure(self):
| class MockElasticIngest(object, ):
'\n Mock of Elasticsearch IndicesClient\n '
def simulate(self, id=None, body=None, verbose=None):
'\n Mock of simulate method\n '
raise TransportError('custom message', 123)
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_simulate, 'foo', 'bar')
|
'Test if mapping creation fails with CEE on invalid elasticsearch-py version'
| def test_pipeline_simulate_wrong_version(self):
| class MockElasticIngest(object, ):
pass
class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
ingest = MockElasticIngest()
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.pipeline_simulate, 'foo', 'bar')
|
'Test if mapping can be created'
| def test_search_template_get(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def get_template(self, id=None):
'\n Mock of get_template method\n '
return {'test': 'key'}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertDictEqual(elasticsearch.search_template_get('foo'), {'test': 'key'})
|
'Test if mapping can be created'
| def test_search_template_get_not(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def get_template(self, id=None):
'\n Mock of get_template method\n '
raise NotFoundError
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertIs(elasticsearch.search_template_get('foo'), None)
|
'Test if mapping creation fails'
| def test_search_template_get_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def get_template(self, id=None):
'\n Mock of get_template method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.search_template_get, 'foo')
|
'Test if mapping can be created'
| def test_search_template_create(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def put_template(self, id=None, body=None):
'\n Mock of put_template method\n '
return {'acknowledged': True}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.search_template_create('foo', 'bar'))
|
'Test if mapping can be created'
| def test_search_template_create_not(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def put_template(self, id=None, body=None):
'\n Mock of put_template method\n '
return {'acknowledged': False}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.search_template_create('foo', 'bar'))
|
'Test if mapping creation fails'
| def test_search_template_create_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def put_template(self, id=None, body=None):
'\n Mock of put_template method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.search_template_create, 'foo', 'bar')
|
'Test if mapping can be deleted'
| def test_search_template_delete(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def delete_template(self, id=None):
'\n Mock of delete_template method\n '
return {'acknowledged': True}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.search_template_delete('foo'))
|
'Test if mapping can be deleted but not acked'
| def test_search_template_delete_not(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def delete_template(self, id=None):
'\n Mock of delete_template method\n '
return {'acknowledged': False}
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertFalse(elasticsearch.search_template_delete('foo'))
|
'Test if deleting mapping doesn\'t exist'
| def test_search_template_delete_not_exists(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def delete_template(self, id=None):
'\n Mock of delete_template method\n '
raise NotFoundError
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertTrue(elasticsearch.search_template_delete('foo'))
|
'Test if mapping deletion fails'
| def test_search_template_delete_failure(self):
| class MockElastic(object, ):
'\n Mock of Elasticsearch client\n '
def delete_template(self, id=None):
'\n Mock of delete_template method\n '
raise TransportError('custom message', 123)
with patch.object(elasticsearch, '_get_instance', MagicMock(return_value=MockElastic())):
self.assertRaises(CommandExecutionError, elasticsearch.search_template_delete, 'foo')
|
'Test if it clear out all of the data in the minion datastore'
| def test_clear(self):
| with patch('os.remove', MagicMock(return_value='')):
with patch.dict(data.__opts__, {'cachedir': ''}):
self.assertTrue(data.clear())
|
'Test if it return all of the data in the minion datastore'
| def test_load(self):
| with patch('salt.payload.Serial.load', MagicMock(return_value=True)):
mocked_fopen = MagicMock(return_value=True)
mocked_fopen.__enter__ = MagicMock(return_value=mocked_fopen)
mocked_fopen.__exit__ = MagicMock()
with patch('salt.utils.files.fopen', MagicMock(return_value=mocked_fopen)):
with patch('salt.payload.Serial.loads', MagicMock(return_value=True)):
with patch.dict(data.__opts__, {'cachedir': '/'}):
self.assertTrue(data.load())
|
'Test if it replace the entire datastore with a passed data structure'
| def test_dump(self):
| with patch.dict(data.__opts__, {'cachedir': '/'}):
with patch('salt.utils.files.fopen', mock_open()):
self.assertTrue(data.dump('{"eggs": "spam"}'))
|
'Test if it replace the entire datastore with a passed data structure'
| def test_dump_isinstance(self):
| with patch('ast.literal_eval', MagicMock(return_value='')):
self.assertFalse(data.dump('salt'))
|
'Test if it replace the entire datastore with a passed data structure'
| def test_dump_ioerror(self):
| with patch.dict(data.__opts__, {'cachedir': '/'}):
mock = MagicMock(side_effect=IOError(''))
with patch('salt.utils.files.fopen', mock):
self.assertFalse(data.dump('{"eggs": "spam"}'))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.