How to use create_association method in localstack

Best Python code snippet using localstack_python

test_base.py

Source:test_base.py Github

copy

Full Screen

...15 """Test cases to validate the endpoint policy driver behavior."""16 @property17 def driver(self):18 raise exception.NotImplemented()19 def create_association(self, **kwargs):20 association = {'policy_id': uuid.uuid4().hex,21 'endpoint_id': None,22 'service_id': None,23 'region_id': None}24 association.update(kwargs)25 self.driver.create_policy_association(**association)26 return association27 def test_create_policy_association(self):28 association = self.create_association(endpoint_id=uuid.uuid4().hex)29 self.driver.check_policy_association(**association)30 association = self.create_association(service_id=uuid.uuid4().hex,31 region_id=uuid.uuid4().hex)32 self.driver.check_policy_association(**association)33 association = self.create_association(service_id=uuid.uuid4().hex)34 self.driver.check_policy_association(**association)35 def test_recreate_policy_association(self):36 # Creating a policy association to a target that already has a policy37 # associated to it will cause the original policy to be overridden38 original_association = self.create_association(39 service_id=uuid.uuid4().hex)40 override_association = original_association.copy()41 override_association['policy_id'] = uuid.uuid4().hex42 self.driver.create_policy_association(**override_association)43 self.driver.check_policy_association(**override_association)44 self.assertRaises(exception.PolicyAssociationNotFound,45 self.driver.check_policy_association,46 **original_association)47 def test_check_policy_association(self):48 association = self.create_association(service_id=uuid.uuid4().hex,49 region_id=uuid.uuid4().hex)50 self.driver.check_policy_association(**association)51 # An association is uniquely identified by its target. Omitting any52 # attribute (region_id in this case) will result in a different check53 association.pop('region_id')54 self.assertRaises(exception.PolicyAssociationNotFound,55 self.driver.check_policy_association,56 **association)57 def test_delete_policy_association(self):58 association = self.create_association(endpoint_id=uuid.uuid4().hex)59 self.driver.delete_policy_association(**association)60 self.assertRaises(exception.PolicyAssociationNotFound,61 self.driver.check_policy_association,62 **association)63 def test_get_policy_association(self):64 association = self.create_association(service_id=uuid.uuid4().hex)65 # Extract the policy_id from the association and query it by the target66 policy_id = association.pop('policy_id')67 association_ref = self.driver.get_policy_association(**association)68 self.assertEqual({'policy_id': (policy_id,)}, association_ref)69 def test_list_associations_for_policy(self):70 policy_id = uuid.uuid4().hex71 first = self.create_association(endpoint_id=uuid.uuid4().hex,72 policy_id=policy_id)73 second = self.create_association(service_id=uuid.uuid4().hex,74 policy_id=policy_id)75 associations = self.driver.list_associations_for_policy(policy_id)76 self.assertItemsEqual([first, second], associations)77 def test_delete_association_by_endpoint(self):78 endpoint_id = uuid.uuid4().hex79 associations = [self.create_association(endpoint_id=endpoint_id),80 self.create_association(endpoint_id=endpoint_id)]81 self.driver.delete_association_by_endpoint(endpoint_id)82 for association in associations:83 self.assertRaises(exception.PolicyAssociationNotFound,84 self.driver.check_policy_association,85 **association)86 def test_delete_association_by_service(self):87 service_id = uuid.uuid4().hex88 associations = [self.create_association(service_id=service_id),89 self.create_association(service_id=service_id)]90 self.driver.delete_association_by_service(service_id)91 for association in associations:92 self.assertRaises(exception.PolicyAssociationNotFound,93 self.driver.check_policy_association,94 **association)95 def test_delete_association_by_region(self):96 region_id = uuid.uuid4().hex97 first = self.create_association(service_id=uuid.uuid4().hex,98 region_id=region_id)99 second = self.create_association(service_id=uuid.uuid4().hex,100 region_id=region_id)101 self.driver.delete_association_by_region(region_id)102 for association in [first, second]:103 self.assertRaises(exception.PolicyAssociationNotFound,104 self.driver.check_policy_association,105 **association)106 def test_delete_association_by_policy(self):107 policy_id = uuid.uuid4().hex108 first = self.create_association(endpoint_id=uuid.uuid4().hex,109 policy_id=policy_id)110 second = self.create_association(service_id=uuid.uuid4().hex,111 policy_id=policy_id)112 self.driver.delete_association_by_policy(policy_id)113 for association in [first, second]:114 self.assertRaises(exception.PolicyAssociationNotFound,115 self.driver.check_policy_association,...

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