Best Python code snippet using localstack_python
test_aliases.py
Source:test_aliases.py
...6class ErrorReportingTestCase(ESTestCase):7 def setUp(self):8 super(ErrorReportingTestCase, self).setUp()9 #self.conn.set_alias('test-alias', ['_river'])10 #self.conn.delete_alias('test-alias', ['_river'])11 self.conn.delete_index_if_exists('test-index2')12 def tearDown(self):13 #self.conn.set_alias('test-alias', ['_river'])14 #self.conn.delete_alias('test-alias', ['_river'])15 self.conn.delete_index_if_exists('test-index2')16 def testCreateDeleteAliases(self):17 """Test errors thrown when creating or deleting aliases.18 """19 self.assertTrue('ok' in self.conn.create_index(self.index_name))20 # Check initial output of get_indices.21 result = self.conn.get_indices(include_aliases=True)22 self.assertTrue('test-index' in result)23 self.assertEqual(result['test-index'], {'num_docs': 0})24 self.assertTrue('test-alias' not in result)25 # Check getting a missing alias.26 err = self.checkRaises(exceptions.IndexMissingException,27 self.conn.get_alias, 'test-alias')28 self.assertEqual(str(err), '[test-alias] missing')29 # Check deleting a missing alias (doesn't return a error).30 self.conn.delete_alias("test-alias", self.index_name)31 # Add an alias from test-alias to test-index32 self.conn.change_aliases([['add', 'test-index', 'test-alias']])33 self.assertEqual(self.conn.get_alias("test-alias"), ['test-index'])34 # Adding an alias to a missing index fails35 err = self.checkRaises(exceptions.IndexMissingException,36 self.conn.change_aliases,37 [['add', 'test-missing-index', 'test-alias']])38 self.assertEqual(str(err), '[test-missing-index] missing')39 self.assertEqual(self.conn.get_alias("test-alias"), ['test-index'])40 # # An alias can't be deleted using delete_index.41 # err = self.checkRaises(exceptions.NotFoundException,42 # self.conn.delete_index, 'test-alias')43 # self.assertEqual(str(err), '[test-alias] missing')44 # Check return value from get_indices now.45 result = self.conn.get_indices(include_aliases=True)46 self.assertTrue('test-index' in result)47 self.assertEqual(result['test-index'], {'num_docs': 0})48 self.assertTrue('test-alias' in result)49 self.assertEqual(result['test-alias'], {'alias_for': ['test-index'], 'num_docs': 0})50 result = self.conn.get_indices(include_aliases=False)51 self.assertTrue('test-index' in result)52 self.assertEqual(result['test-index'], {'num_docs': 0})53 self.assertTrue('test-alias' not in result)54 # Add an alias to test-index2.55 self.assertTrue('ok' in self.conn.create_index("test-index2"))56 self.conn.change_aliases([['add', 'test-index2', 'test-alias']])57 self.assertEqual(sorted(self.conn.get_alias("test-alias")),58 ['test-index', 'test-index2'])59 # Check deleting multiple indices from an alias.60 self.conn.delete_alias("test-alias", [self.index_name, "test-index2"])61 self.checkRaises(exceptions.IndexMissingException, self.conn.get_alias, 'test-alias')62 # Check deleting multiple indices from a missing alias (still no error)63 self.conn.delete_alias("test-alias", [self.index_name, "test-index2"])64 # Check that we still get an error for a missing alias.65 err = self.checkRaises(exceptions.IndexMissingException,66 self.conn.get_alias, 'test-alias')67 self.assertEqual(str(err), '[test-alias] missing')68 def testWriteToAlias(self):69 self.assertTrue('ok' in self.conn.create_index(self.index_name))70 self.assertTrue('ok' in self.conn.create_index("test-index2"))71 self.assertTrue('ok' in self.conn.set_alias("test-alias", ['test-index']))72 self.assertTrue('ok' in self.conn.set_alias("test-alias2", ['test-index', 'test-index2']))73 # Can write to aliases only if they point to exactly one index.74 self.conn.index(dict(title='doc1'), 'test-index', 'testtype')75 self.conn.index(dict(title='doc1'), 'test-index2', 'testtype')76 self.conn.index(dict(title='doc1'), 'test-alias', 'testtype')77 self.checkRaises(exceptions.ElasticSearchIllegalArgumentException,...
sample_index_alias_crud_operations.py
Source:sample_index_alias_crud_operations.py
...70 result_index = client.create_or_update_index(index=index)71 alias = SearchAlias(name = alias_name, indexes = [new_index_name])72 result = client.create_or_update_alias(alias)73 # [END update_alias]74def delete_alias():75 # [START delete_alias]76 client.delete_alias(alias_name)77 # [END delete_alias]78if __name__ == '__main__':79 create_alias()80 get_alias()81 update_alias()...
urls.py
Source:urls.py
1"""aliases URL Configuration"""2from django.conf.urls import url3from . import views4urlpatterns = [5 url(6 r'^$',7 views.dashboard,8 name='dashboard'9 ),10 url(11 r'^(?P<alias>\w+)/$',12 views.click,13 name='click'14 ),15 url(16 r'^alias/new/$',17 views.new_alias,18 name='new_alias'19 ),20 url(21 r'^alias/edit/$',22 views.edit_alias,23 name='edit_alias'24 ),25 url(26 r'^alias/delete/$',27 views.delete_alias,28 name='delete_alias'29 ),...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!