Best Python code snippet using localstack_python
test_resourcegroups.py
Source:test_resourcegroups.py
...3import json4import sure # noqa5from moto import mock_resourcegroups6@mock_resourcegroups7def test_create_group():8 resource_groups = boto3.client("resource-groups", region_name="us-east-1")9 response = resource_groups.create_group(10 Name="test_resource_group",11 Description="description",12 ResourceQuery={13 "Type": "TAG_FILTERS_1_0",14 "Query": json.dumps(15 {16 "ResourceTypeFilters": ["AWS::AllSupported"],17 "TagFilters": [18 {"Key": "resources_tag_key", "Values": ["resources_tag_value"]}19 ],20 }21 ),22 },23 Tags={"resource_group_tag_key": "resource_group_tag_value"},24 )25 response["Group"]["Name"].should.contain("test_resource_group")26 response["ResourceQuery"]["Type"].should.contain("TAG_FILTERS_1_0")27 response["Tags"]["resource_group_tag_key"].should.contain(28 "resource_group_tag_value"29 )30@mock_resourcegroups31def test_delete_group():32 resource_groups = boto3.client("resource-groups", region_name="us-east-1")33 test_create_group()34 response = resource_groups.delete_group(GroupName="test_resource_group")35 response["Group"]["Name"].should.contain("test_resource_group")36 response = resource_groups.list_groups()37 response["GroupIdentifiers"].should.have.length_of(0)38 response["Groups"].should.have.length_of(0)39@mock_resourcegroups40def test_get_group():41 resource_groups = boto3.client("resource-groups", region_name="us-east-1")42 test_create_group()43 response = resource_groups.get_group(GroupName="test_resource_group")44 response["Group"]["Description"].should.contain("description")45 return response46@mock_resourcegroups47def test_get_group_query():48 resource_groups = boto3.client("resource-groups", region_name="us-east-1")49 test_create_group()50 response = resource_groups.get_group_query(GroupName="test_resource_group")51 response["GroupQuery"]["ResourceQuery"]["Type"].should.contain("TAG_FILTERS_1_0")52@mock_resourcegroups53def test_get_tags():54 resource_groups = boto3.client("resource-groups", region_name="us-east-1")55 response = test_get_group()56 response = resource_groups.get_tags(Arn=response["Group"]["GroupArn"])57 response["Tags"].should.have.length_of(1)58 response["Tags"]["resource_group_tag_key"].should.contain(59 "resource_group_tag_value"60 )61 return response62@mock_resourcegroups63def test_list_groups():64 resource_groups = boto3.client("resource-groups", region_name="us-east-1")65 test_create_group()66 response = resource_groups.list_groups()67 response["GroupIdentifiers"].should.have.length_of(1)68 response["Groups"].should.have.length_of(1)69@mock_resourcegroups70def test_tag():71 resource_groups = boto3.client("resource-groups", region_name="us-east-1")72 response = test_get_tags()73 response = resource_groups.tag(74 Arn=response["Arn"],75 Tags={"resource_group_tag_key_2": "resource_group_tag_value_2"},76 )77 response["Tags"]["resource_group_tag_key_2"].should.contain(78 "resource_group_tag_value_2"79 )80 response = resource_groups.get_tags(Arn=response["Arn"])81 response["Tags"].should.have.length_of(2)82 response["Tags"]["resource_group_tag_key_2"].should.contain(83 "resource_group_tag_value_2"84 )85@mock_resourcegroups86def test_untag():87 resource_groups = boto3.client("resource-groups", region_name="us-east-1")88 response = test_get_tags()89 response = resource_groups.untag(90 Arn=response["Arn"], Keys=["resource_group_tag_key"]91 )92 response["Keys"].should.contain("resource_group_tag_key")93 response = resource_groups.get_tags(Arn=response["Arn"])94 response["Tags"].should.have.length_of(0)95@mock_resourcegroups96def test_update_group():97 resource_groups = boto3.client("resource-groups", region_name="us-east-1")98 test_get_group()99 response = resource_groups.update_group(100 GroupName="test_resource_group", Description="description_2"101 )102 response["Group"]["Description"].should.contain("description_2")103 response = resource_groups.get_group(GroupName="test_resource_group")104 response["Group"]["Description"].should.contain("description_2")105@mock_resourcegroups106def test_update_group_query():107 resource_groups = boto3.client("resource-groups", region_name="us-east-1")108 test_create_group()109 response = resource_groups.update_group_query(110 GroupName="test_resource_group",111 ResourceQuery={112 "Type": "CLOUDFORMATION_STACK_1_0",113 "Query": json.dumps(114 {115 "ResourceTypeFilters": ["AWS::AllSupported"],116 "StackIdentifier": (117 "arn:aws:cloudformation:eu-west-1:012345678912:stack/"118 "test_stack/c223eca0-e744-11e8-8910-500c41f59083"119 ),120 }121 ),122 },...
group_test.py
Source:group_test.py
...10 if dictRet is None:11 g_logger.info("FXXK")12 return13 g_logger.info(obj2json(dictRet))14async def test_create_group():15 dictRet = await GroupService.create_group("FXXK3")16 if dictRet is None:17 g_logger.info("FXXK Failed")18 return19 g_logger.info(obj2json(dictRet))20 ret = await GroupService.add_user_to_group(10000008, dictRet["id"])21 g_logger.info(ret)22async def test():23 await test_get_group()24 await test_create_group()25def main():26 # await test_query_user_by_name()27 loop = asyncio.get_event_loop()28 asyncio.gather(test())29 loop.run_forever()30if __name__ == '__main__':...
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!!