adds tagging support for cloudwatch events service
This commit is contained in:
parent
d596560971
commit
6cb0428d20
5 changed files with 201 additions and 8 deletions
53
tests/test_utilities/test_tagging_service.py
Normal file
53
tests/test_utilities/test_tagging_service.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import unittest
|
||||
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
|
||||
class TestTaggingService(unittest.TestCase):
|
||||
def test_list_empty(self):
|
||||
svc = TaggingService()
|
||||
result = svc.list_tags_for_resource('test')
|
||||
self.assertEqual(result, {'Tags': []})
|
||||
|
||||
def test_create_tag(self):
|
||||
svc = TaggingService('TheTags', 'TagKey', 'TagValue')
|
||||
tags = [{'TagKey': 'key_key', 'TagValue': 'value_value'}]
|
||||
svc.tag_resource('arn', tags)
|
||||
actual = svc.list_tags_for_resource('arn')
|
||||
expected = {'TheTags': [{'TagKey': 'key_key', 'TagValue': 'value_value'}]}
|
||||
self.assertDictEqual(expected, actual)
|
||||
|
||||
def test_create_tag_without_value(self):
|
||||
svc = TaggingService()
|
||||
tags = [{'Key': 'key_key'}]
|
||||
svc.tag_resource('arn', tags)
|
||||
actual = svc.list_tags_for_resource('arn')
|
||||
expected = {'Tags': [{'Key': 'key_key', 'Value': ''}]}
|
||||
self.assertDictEqual(expected, actual)
|
||||
|
||||
def test_delete_tag(self):
|
||||
svc = TaggingService()
|
||||
tags = [{'Key': 'key_key', 'Value': 'value_value'}]
|
||||
svc.tag_resource('arn', tags)
|
||||
svc.untag_resource('arn', ['key_key'])
|
||||
result = svc.list_tags_for_resource('arn')
|
||||
self.assertEqual(
|
||||
result, {'Tags': []})
|
||||
|
||||
def test_list_empty_delete(self):
|
||||
svc = TaggingService()
|
||||
svc.untag_resource('arn', ['key_key'])
|
||||
result = svc.list_tags_for_resource('arn')
|
||||
self.assertEqual(
|
||||
result, {'Tags': []})
|
||||
|
||||
def test_extract_tag_names(self):
|
||||
svc = TaggingService()
|
||||
tags = [{'Key': 'key1', 'Value': 'value1'}, {'Key': 'key2', 'Value': 'value2'}]
|
||||
actual = svc.extract_tag_names(tags)
|
||||
expected = ['key1', 'key2']
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue