Best Python code snippet using localstack_python
tag_resource.py
Source:tag_resource.py
...50 """51 logger.info("Let's add tags {} for resource with arn: {}...".format(tags, resource_arn))52 qldb_client.tag_resource(ResourceArn=resource_arn, Tags=tags)53 logger.info('Successfully added tags.')54def untag_resource(resource_arn, tag_keys):55 """56 Remove one or more tags from the specified QLDB resource.57 :type resource_arn: dict58 :param resource_arn: The Amazon Resource Name (ARN) of the ledger from which to remove the tags.59 :type tag_keys: list60 :param tag_keys: The list of tag keys to remove.61 """62 logger.info("Let's remove tags {} for resource with arn: {}.".format(tag_keys, resource_arn))63 qldb_client.untag_resource(ResourceArn=resource_arn, TagKeys=tag_keys)64 logger.info('Successfully removed tags.')65def list_tags(resource_arn):66 """67 Returns all tags for a specified Amazon QLDB resource.68 :type resource_arn: dict69 :param resource_arn: The Amazon Resource Name (ARN) for which to list tags off.70 :rtype: dict71 :return: All tags on the specified resource.72 """73 logger.info("Let's list the tags for resource with arn: {}.".format(resource_arn))74 result = qldb_client.list_tags_for_resource(ResourceArn=resource_arn)75 logger.info('Success. Tags: {}.'.format(result.get('Tags')))76 return result77def main(ledger_name=Constants.LEDGER_NAME_WITH_TAGS):78 """79 Tagging and un-tagging resources, including tag on create.80 """81 try:82 result = create_with_tags(ledger_name, CREATE_TAGS)83 wait_for_active(ledger_name)84 ARN = result.get('Arn')85 list_tags(ARN)86 untag_resource(ARN, REMOVE_TAGS)87 list_tags(ARN)88 tag_resource(ARN, ADD_TAGS)89 list_tags(ARN)90 except Exception as e:91 logger.exception('Unable to tag or untag resources!')92 raise e93if __name__ == '__main__':...
test_tagging.py
Source:test_tagging.py
...13 self.assertDictEqual(expected, actual)14 def test_delete_tag(self):15 tags = [{'Key': 'key_key', 'Value': 'value_value'}]16 self.svc.tag_resource('arn', tags)17 self.svc.untag_resource('arn', ['key_key'])18 result = self.svc.list_tags_for_resource('arn')19 self.assertEqual(20 result, {'Tags': []})21 def test_list_empty_delete(self):22 self.svc.untag_resource('arn', ['key_key'])23 result = self.svc.list_tags_for_resource('arn')24 self.assertEqual(...
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!!