Best Python code snippet using localstack_python
test_route53resolver_rule_associations.py
Source:test_route53resolver_rule_associations.py  
...105    # Not testing "Too many rule associations" as it takes too long to create106    # 2000 VPCs and rule associations.107@mock_ec2108@mock_route53resolver109def test_route53resolver_disassociate_resolver_rule():110    """Test good disassociate_resolver_rule API calls."""111    client = boto3.client("route53resolver", region_name=TEST_REGION)112    ec2_client = boto3.client("ec2", region_name=TEST_REGION)113    created_association = create_test_rule_association(client, ec2_client)114    # Disassociate the resolver rule and verify the response.115    response = client.disassociate_resolver_rule(116        ResolverRuleId=created_association["ResolverRuleId"],117        VPCId=created_association["VPCId"],118    )119    association = response["ResolverRuleAssociation"]120    assert association["Id"] == created_association["Id"]121    assert association["ResolverRuleId"] == created_association["ResolverRuleId"]122    assert association["Name"] == created_association["Name"]123    assert association["VPCId"] == created_association["VPCId"]124    assert association["Status"] == "DELETING"125    assert "Deleting" in association["StatusMessage"]126@mock_ec2127@mock_route53resolver128def test_route53resolver_bad_disassociate_resolver_rule():129    """Test disassociate_resolver_rule API calls with a bad ID."""130    client = boto3.client("route53resolver", region_name=TEST_REGION)131    ec2_client = boto3.client("ec2", region_name=TEST_REGION)132    random_num = get_random_hex(10)133    # Use a resolver rule id and vpc id that is too long.134    long_id = "0123456789" * 6 + "xxxxx"135    long_vpc_id = random_num * 6 + "12345"136    with pytest.raises(ClientError) as exc:137        client.disassociate_resolver_rule(ResolverRuleId=long_id, VPCId=long_vpc_id)138    err = exc.value.response["Error"]139    assert err["Code"] == "ValidationException"140    assert "2 validation errors detected" in err["Message"]141    assert (142        f"Value '{long_id}' at 'resolverRuleId' failed to satisfy "143        f"constraint: Member must have length less than or equal to 64"144    ) in err["Message"]145    assert (146        f"Value '{long_vpc_id}' at 'vPCId' failed to satisfy "147        f"constraint: Member must have length less than or equal to 64"148    ) in err["Message"]149    # Create a test association.150    test_association = create_test_rule_association(client, ec2_client)151    test_rule_id = test_association["ResolverRuleId"]152    test_vpc_id = test_association["VPCId"]153    # Disassociate from a non-existent resolver rule id.154    with pytest.raises(ClientError) as exc:155        client.disassociate_resolver_rule(ResolverRuleId=random_num, VPCId=test_vpc_id)156    err = exc.value.response["Error"]157    assert err["Code"] == "ResourceNotFoundException"158    assert f"Resolver rule with ID '{random_num}' does not exist" in err["Message"]159    # Disassociate using a non-existent vpc id.160    with pytest.raises(ClientError) as exc:161        client.disassociate_resolver_rule(ResolverRuleId=test_rule_id, VPCId=random_num)162    err = exc.value.response["Error"]163    assert err["Code"] == "ResourceNotFoundException"164    assert (165        f"Resolver Rule Association between Resolver Rule "166        f"'{test_rule_id}' and VPC '{random_num}' does not exist"167    ) in err["Message"]168    # Disassociate successfully, then test that it's not possible to169    # disassociate again.170    client.disassociate_resolver_rule(ResolverRuleId=test_rule_id, VPCId=test_vpc_id)171    with pytest.raises(ClientError) as exc:172        client.disassociate_resolver_rule(173            ResolverRuleId=test_rule_id, VPCId=test_vpc_id174        )175    err = exc.value.response["Error"]176    assert err["Code"] == "ResourceNotFoundException"177    assert (178        f"Resolver Rule Association between Resolver Rule "179        f"'{test_rule_id}' and VPC '{test_vpc_id}' does not exist"180    ) in err["Message"]181@mock_ec2182@mock_route53resolver183def test_route53resolver_get_resolver_rule_association():184    """Test good get_resolver_rule_association API calls."""185    client = boto3.client("route53resolver", region_name=TEST_REGION)186    ec2_client = boto3.client("ec2", region_name=TEST_REGION)...client.py
Source:client.py  
...21    def delete_resolver_rule(self, ResolverRuleId: str) -> Dict:22        pass23    def disassociate_resolver_endpoint_ip_address(self, ResolverEndpointId: str, IpAddress: Dict) -> Dict:24        pass25    def disassociate_resolver_rule(self, VPCId: str, ResolverRuleId: str) -> Dict:26        pass27    def generate_presigned_url(self, ClientMethod: str = None, Params: Dict = None, ExpiresIn: int = None, HttpMethod: str = None):28        pass29    def get_paginator(self, operation_name: str = None) -> Paginator:30        pass31    def get_resolver_endpoint(self, ResolverEndpointId: str) -> Dict:32        pass33    def get_resolver_rule(self, ResolverRuleId: str) -> Dict:34        pass35    def get_resolver_rule_association(self, ResolverRuleAssociationId: str) -> Dict:36        pass37    def get_resolver_rule_policy(self, Arn: str) -> Dict:38        pass39    def get_waiter(self, waiter_name: str = None) -> Waiter:...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!!
