Best Python code snippet using localstack_python
test_tags.py
Source:test_tags.py
...41 # Act & Assert42 self.assertRaises(43 PcpError, lambda: self.tags.tag_resources([sample_arn], sample_tags)44 )45 def test_untag_resources(self) -> None:46 # Arrange47 sample_arn = "arn:aws:vpc:us-west-2:123456:vpc/vpc-1234abcd"48 sample_tag_key = "tag_name"49 client_return_response = {"FailedResourcesMap": {}}50 self.aws_tags.untag_resources = MagicMock(return_value=client_return_response)51 # Act52 self.tags.untag_resources([sample_arn], [sample_tag_key])53 # Assert54 self.aws_tags.untag_resources.assert_called()55 def test_untag_resources_failure_throws(self) -> None:56 # Arrange57 sample_arn = "arn:aws:vpc:us-west-2:123456:vpc/vpc-1234abcd"58 sample_tag_key = "tag_name"59 client_return_response = {60 "FailedResourcesMap": {61 sample_arn: {62 "StatusCode": 400,63 "ErrorCode": "InvalidParameterException",64 }65 }66 }67 self.aws_tags.untag_resources = MagicMock(return_value=client_return_response)68 # Act & Assert69 self.assertRaises(70 PcpError, lambda: self.tags.untag_resources([sample_arn], [sample_tag_key])71 )72 def test_get_resources(self) -> None:73 # Arrange74 client_return_response = {75 "PaginationToken": "string",76 "ResourceTagMappingList": [77 {78 "ResourceARN": "arn:aws:vpc:us-west-2:123456:vpc/vpc-1234abcd",79 "Tags": [80 {"Key": "pce-id", "Value": "1234abcd"},81 ],82 "ComplianceDetails": {83 "NoncompliantKeys": [84 "string",...
tags.py
Source:tags.py
...27 endpoint="tags/{name}/resources".format(name=name),28 method="post",29 json=post_json,30 )31 def untag_resources(self, name: str, resources: List[models.Tag.Resource]) -> None:32 post_json = {"resources": [res.dict() for res in resources]}33 self._client.request(34 endpoint="tags/{name}/resources".format(name=name),35 method="delete",36 json=post_json,37 )38class AsyncTagsManager(AsyncBaseManager):39 endpoint = "tags"40 name = "tags"41 async def all(self) -> List[models.Tag]:42 res = await self._client.fetch_all(endpoint="tags", key="tags")43 return [models.Tag(**tag) for tag in res]44 async def get(self, name: str) -> models.Tag:45 res = await self._client.request(46 endpoint="tags/{name}".format(name=name), method="get"47 )48 return models.Tag(**res["tag"])49 async def create(self, tag: models.Tag) -> models.Tag:50 res = await self._client.request(51 endpoint="tags", method="post", data=tag.json(include={"name"}),52 )53 return models.Tag(**res["tag"])54 async def delete(self, tag: models.Tag) -> None:55 await self._client.request(56 endpoint="tags/{name}".format(name=tag.name), method="delete",57 )58 async def tag_resources(59 self, name: str, resources: List[models.Tag.Resource]60 ) -> None:61 post_json = {"resources": [res.dict() for res in resources]}62 await self._client.request(63 endpoint="tags/{name}/resources".format(name=name),64 method="post",65 json=post_json,66 )67 async def untag_resources(68 self, name: str, resources: List[models.Tag.Resource]69 ) -> None:70 post_json = {"resources": [res.dict() for res in resources]}71 await self._client.request(72 endpoint="tags/{name}/resources".format(name=name),73 method="delete",74 json=post_json,...
tag_provider.py
Source:tag_provider.py
...58 self.success("no changes")59 def delete_old(self):60 keys = list(self.old_tags.keys())61 if keys:62 response = self.rg_tagging.untag_resources(63 ResourceARNList=self.resource_arns, TagKeys=keys64 )65 def delete(self):66 keys = list(self.tags.keys())67 if keys:68 response = self.rg_tagging.untag_resources(69 ResourceARNList=self.resource_arns, TagKeys=keys70 )71provider = TagProvider()72def handler(request, context):...
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!!