How to use create_alias method in localstack

Best Python code snippet using localstack_python

tests.py

Source:tests.py Github

copy

Full Screen

...16 self.assertTrue(sl.has('simple-service'))17 def test_has_alias_exists(self):18 sl = ServiceLocator()19 sl.set('simple-service', lambda: 26 )20 sl.create_alias('s-s', 'simple-service')21 self.assertTrue(sl.has('simple-service'))22######## sl.set() tests ################23 def test_set_empty(self):24 sl = ServiceLocator()25 with self.assertRaises(NameError):26 sl.set('', lambda: "test")27 def test_set_with_values(self):28 def simple_service():29 return "text"30 sl = ServiceLocator()31 sl.set('simple-service', simple_service)32 self.assertTrue(sl.has('simple-service'))33 def test_set_double(self):34 def simple_service():35 return "text"36 def simple_service2():37 return "text"38 sl = ServiceLocator()39 with self.assertRaises(KeyError):40 sl.set('simple-service', simple_service)41 sl.set('simple-service', simple_service2)42 def test_set_alias_exist(self):43 def simple_service():44 return "text"45 def simple_service2():46 return "text"47 sl = ServiceLocator()48 sl.set('simple-service', simple_service)49 sl.create_alias('s-s', 'simple-service')50 with self.assertRaises(KeyError):51 sl.set('s-s', simple_service2)52 def test_set_double_override(self):53 def simple_service():54 return "text"55 def simple_service2():56 return "text2"57 sl = ServiceLocator()58 sl.set('simple-service', simple_service)59 #shouldn't generate any error60 sl.set('simple-service', simple_service2, can_override=True)61 #simple-service should point to simple_service2 now62 self.assertEqual(sl.get('simple-service'), 'text2')63 def test_set_non_callable(self):64 sl = ServiceLocator()65 o = 12366 with self.assertRaises(ValueError):67 sl.set('wrong-service', o)68######## sl.get() tests ################69 def test_get_not_exists(self):70 sl = ServiceLocator()71 with self.assertRaises(KeyError):72 sl.get('non-exists-service')73 def test_get_exists(self):74 def serv():75 return "1-2-3"76 sl = ServiceLocator()77 sl.set('test-service', serv)78 val = sl.get('test-service')79 self.assertEqual(val, '1-2-3')80 def test_get_alias_exists(self):81 def serv():82 return "1-2-3"83 sl = ServiceLocator()84 sl.set('test-service', serv)85 sl.create_alias('t-s', 'test-service')86 val = sl.get('t-s')87 self.assertEqual(val, '1-2-3')88 stored_value = 589 def test_get_value_cache(self):90 def serv():91 self.stored_value = self.stored_value ** 292 return self.stored_value93 sl = ServiceLocator()94 sl.set('test-service', serv)95 val = sl.get('test-service')96 self.assertEqual(val, 25)97 val2 = sl.get('test-service')98 self.assertEqual(val2, 25)99 val3 = sl.get('test-service')100 self.assertEqual(val3, 25)101######### sl.create_alias() tests ############102 def test_create_empty_alias(self):103 sl = ServiceLocator()104 with self.assertRaises(NameError):105 sl.create_alias('', '')106 def test_create_alias_service_non_exists(self):107 sl = ServiceLocator()108 with self.assertRaises(KeyError):109 sl.create_alias('test', 'non-exists-service')110 def test_create_alias_name_reserved(self):111 sl = ServiceLocator()112 sl.set('serv', lambda: 'test')113 sl.create_alias('test', 'serv')114 with self.assertRaises(KeyError):115 sl.create_alias('test', 'serv')116 with self.assertRaises(KeyError):117 sl.create_alias('serv', 'test')118 def test_create_alias(self):119 sl = ServiceLocator()120 sl.set('service-1', lambda: "test-value")121 sl.create_alias('test', 'service-1')122 self.assertEqual(sl.get('test'),'test-value')123 def test_multiple_aliases_stack(self):124 sl = ServiceLocator()125 sl.set('service-1', lambda: "test-value")126 sl.create_alias('test', 'service-1')127 sl.create_alias('test2', 'test')128 sl.create_alias('checking', 'test2')129 sl.create_alias('para-pam', 'checking')130 sl.create_alias('pom-pom', 'test2')131 self.assertEqual(sl.get('test'),'test-value')132 self.assertEqual(sl.get('test2'),'test-value')133 self.assertEqual(sl.get('checking'),'test-value')134 self.assertEqual(sl.get('para-pam'),'test-value')135 self.assertEqual(sl.get('pom-pom'),'test-value')...

Full Screen

Full Screen

alias.py

Source:alias.py Github

copy

Full Screen

...6 def test_get_active_result(self):7 """8 get_active() should return only active aliases9 """10 alias1 = create_alias( 'll="ls -l"',active=False)11 alias2 = create_alias('lll="ls -l|less"')12 self.assertEqual(Alias.objects.get_active().count(), 1)13 self.assertEqual(Alias.objects.get_active()[0], alias2)14 def test_active_default_value(self):15 """16 The active field default value should be False.17 """18 alias = Alias.objects.create(19 content='ll="ls -l"',20 description='Extended output for ls',21 )22 self.assertFalse(alias.active)23class AliasViewTest(TestCase):24 def test_index_view_with_no_alias(self):25 """26 If no alias exist, an appropriate message should be displayed.27 """28 response = self.client.get(reverse('aliases:index'))29 self.assertEqual(response.status_code, 200)30 self.assertContains(response, "No alias")31 self.assertQuerysetEqual(response.context['aliases'], [])32 def test_index_view_with_an_alias(self):33 """34 Valide alias should be displayed.35 """36 alias = create_alias("ll='ls -l'")37 response = self.client.get(reverse('aliases:index'))38 self.assertEqual(response.status_code, 200)39 self.assertQuerysetEqual(response.context['aliases'], ["<Alias: ll='ls -l'>"])40 def test_index_view_with_an_inactive_alias(self):41 """42 Only valide alias should be displayed.43 """44 alias = create_alias("ll='ls -l'",active=False)45 response = self.client.get(reverse('aliases:index'))46 self.assertEqual(response.status_code, 200)47 self.assertQuerysetEqual(response.context['aliases'], [])48 def test_show_view_without_alias(self):49 """50 No alias means 40451 """52 response = self.client.get(reverse('aliases:show', args=(123,)))53 self.assertEqual(response.status_code, 404)54 def test_show_view_on_inactive_alias(self):55 """56 Requesting an inactive alias means 40457 """58 alias = create_alias("ll='ls -l'", active=False)59 response = self.client.get(reverse('aliases:show', args=(alias.id,)))...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1from django.urls import path2from .views import create_alias, get_target_by_alias3urlpatterns = [4 path('create_alias/', create_alias, name='create_alias'),5 path('get_object/', get_target_by_alias, name='get_target'),...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful