How to use list_resolver_rule_associations method in localstack

Best Python code snippet using localstack_python

test_route53resolver_rule_associations.py

Source:test_route53resolver_rule_associations.py Github

copy

Full Screen

...220 assert err["Code"] == "ResourceNotFoundException"221 assert f"ResolverRuleAssociation '{random_num}' does not Exist" in err["Message"]222@mock_ec2223@mock_route53resolver224def test_route53resolver_list_resolver_rule_associations():225 """Test good list_resolver_rule_associations API calls."""226 client = boto3.client("route53resolver", region_name=TEST_REGION)227 ec2_client = boto3.client("ec2", region_name=TEST_REGION)228 random_num = get_random_hex(10)229 # List rule associations when there are none.230 response = client.list_resolver_rule_associations()231 assert len(response["ResolverRuleAssociations"]) == 0232 assert response["MaxResults"] == 10233 assert "NextToken" not in response234 # Create 4 associations, verify all are listed when no filters, max_results.235 for idx in range(4):236 create_test_rule_association(client, ec2_client, name=f"A{idx}-{random_num}")237 response = client.list_resolver_rule_associations()238 associations = response["ResolverRuleAssociations"]239 assert len(associations) == 4240 assert response["MaxResults"] == 10241 for idx in range(4):242 assert associations[idx]["Name"].startswith(f"A{idx}")243 # Set max_results to return 1 association, use next_token to get244 # remaining 3.245 response = client.list_resolver_rule_associations(MaxResults=1)246 associations = response["ResolverRuleAssociations"]247 assert len(associations) == 1248 assert response["MaxResults"] == 1249 assert "NextToken" in response250 assert associations[0]["Name"].startswith("A0")251 response = client.list_resolver_rule_associations(NextToken=response["NextToken"])252 associations = response["ResolverRuleAssociations"]253 assert len(associations) == 3254 assert response["MaxResults"] == 10255 assert "NextToken" not in response256 for idx, association in enumerate(associations):257 assert association["Name"].startswith(f"A{idx + 1}")258@mock_ec2259@mock_route53resolver260def test_route53resolver_list_resolver_rule_associations_filters():261 """Test good list_resolver_rule_associations API calls that use filters."""262 client = boto3.client("route53resolver", region_name=TEST_REGION)263 ec2_client = boto3.client("ec2", region_name=TEST_REGION)264 random_num = get_random_hex(10)265 # Create some rule associations for testing purposes266 vpc_id1 = create_vpc(ec2_client)267 vpc_id2 = create_vpc(ec2_client)268 associations = []269 rule_ids = ["zero_offset"]270 for idx in range(1, 5):271 association = create_test_rule_association(272 client,273 ec2_client,274 name=f"F{idx}-{random_num}",275 vpc_id=vpc_id1 if idx % 2 else vpc_id2,276 )277 associations.append(association)278 rule_ids.append(association["ResolverRuleId"])279 # Try all the valid filter names, including some of the old style names.280 response = client.list_resolver_rule_associations(281 Filters=[{"Name": "ResolverRuleId", "Values": [rule_ids[3]]}]282 )283 assert len(response["ResolverRuleAssociations"]) == 1284 assert response["ResolverRuleAssociations"][0]["ResolverRuleId"] == rule_ids[3]285 response = client.list_resolver_rule_associations(286 Filters=[{"Name": "RESOLVER_RULE_ID", "Values": [rule_ids[2], rule_ids[4]]}]287 )288 assert len(response["ResolverRuleAssociations"]) == 2289 assert response["ResolverRuleAssociations"][0]["ResolverRuleId"] == rule_ids[2]290 assert response["ResolverRuleAssociations"][1]["ResolverRuleId"] == rule_ids[4]291 response = client.list_resolver_rule_associations(292 Filters=[{"Name": "VPCId", "Values": [vpc_id2]}]293 )294 assert len(response["ResolverRuleAssociations"]) == 2295 response = client.list_resolver_rule_associations(296 Filters=[{"Name": "Name", "Values": [f"F1-{random_num}"]}]297 )298 assert len(response["ResolverRuleAssociations"]) == 1299 assert response["ResolverRuleAssociations"][0]["Name"] == f"F1-{random_num}"300 response = client.list_resolver_rule_associations(301 Filters=[302 {"Name": "VPC_ID", "Values": [vpc_id1]},303 {"Name": "NAME", "Values": [f"F3-{random_num}"]},304 ]305 )306 assert len(response["ResolverRuleAssociations"]) == 1307 assert response["ResolverRuleAssociations"][0]["Name"] == f"F3-{random_num}"308 response = client.list_resolver_rule_associations(309 Filters=[{"Name": "Status", "Values": ["COMPLETE"]}]310 )311 assert len(response["ResolverRuleAssociations"]) == 4312 response = client.list_resolver_rule_associations(313 Filters=[{"Name": "Status", "Values": ["CREATING"]}]314 )315 assert len(response["ResolverRuleAssociations"]) == 0316@mock_route53resolver317def test_route53resolver_bad_list_resolver_rule_associations_filters():318 """Test bad list_resolver_rule_associations API calls that use filters."""319 client = boto3.client("route53resolver", region_name=TEST_REGION)320 # botocore barfs on an empty "Values":321 # TypeError: list_resolver_rule_associations() only accepts keyword arguments.322 # client.list_resolver_rule_associations([{"Name": "Direction", "Values": []}])323 # client.list_resolver_rule_associations([{"Values": []}])324 with pytest.raises(ClientError) as exc:325 client.list_resolver_rule_associations(326 Filters=[{"Name": "foo", "Values": ["bar"]}]327 )328 err = exc.value.response["Error"]329 assert err["Code"] == "InvalidParameterException"330 assert "The filter 'foo' is invalid" in err["Message"]331 with pytest.raises(ClientError) as exc:332 client.list_resolver_rule_associations(333 Filters=[{"Name": "VpcId", "Values": ["bar"]}]334 )335 err = exc.value.response["Error"]336 assert err["Code"] == "InvalidParameterException"337 assert "The filter 'VpcId' is invalid" in err["Message"]338@mock_ec2339@mock_route53resolver340def test_route53resolver_bad_list_resolver_rule_associations():341 """Test bad list_resolver_rule_associations API calls."""342 client = boto3.client("route53resolver", region_name=TEST_REGION)343 ec2_client = boto3.client("ec2", region_name=TEST_REGION)344 # Bad max_results.345 create_test_rule_association(client, ec2_client)346 with pytest.raises(ClientError) as exc:347 client.list_resolver_rule_associations(MaxResults=250)348 err = exc.value.response["Error"]349 assert err["Code"] == "ValidationException"350 assert "1 validation error detected" in err["Message"]351 assert (352 "Value '250' at 'maxResults' failed to satisfy constraint: Member "353 "must have length less than or equal to 100"...

Full Screen

Full Screen

route53resolver.py

Source:route53resolver.py Github

copy

Full Screen

...24 service_code = 'route53resolver'25 quota_code = 'L-94E19253'26 @property27 def current(self):...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1"""Pagination control model for Route53Resolver."""2from .exceptions import InvalidNextTokenException3PAGINATION_MODEL = {4 "list_resolver_endpoint_ip_addresses": {5 "input_token": "next_token",6 "limit_key": "max_results",7 "limit_default": 100,8 "unique_attribute": "IpId",9 },10 "list_resolver_endpoints": {11 "input_token": "next_token",12 "limit_key": "max_results",13 "limit_default": 100,14 "unique_attribute": "id",15 "fail_on_invalid_token": InvalidNextTokenException,16 },17 "list_resolver_rules": {18 "input_token": "next_token",19 "limit_key": "max_results",20 "limit_default": 100,21 "unique_attribute": "id",22 },23 "list_resolver_rule_associations": {24 "input_token": "next_token",25 "limit_key": "max_results",26 "limit_default": 100,27 "unique_attribute": "id",28 },29 "list_tags_for_resource": {30 "input_token": "next_token",31 "limit_key": "max_results",32 "limit_default": 100,33 "unique_attribute": "Key",34 "fail_on_invalid_token": InvalidNextTokenException,35 },...

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