forked from cloud-custodian/cloud-custodian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pinpoint.py
57 lines (53 loc) · 1.93 KB
/
test_pinpoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from .common import BaseTest
class PinpointApp(BaseTest):
def test_pinpoint_app_tag(self):
session_factory = self.replay_flight_data('test_pinpoint_app_tag')
p = self.load_policy(
{
'name': 'test-pinpoint-app-tag',
'resource': 'pinpoint-app',
'filters': [
{
'tag:foo': 'absent',
}
],
'actions': [
{
'type': 'tag',
'tags': {'foo': 'bar'}
}
]
}, session_factory=session_factory
)
resources = p.run()
self.assertEqual(len(resources), 1)
client = session_factory().client('pinpoint')
tags = client.list_tags_for_resource(ResourceArn=resources[0]['Arn'])['TagsModel']['tags']
self.assertEqual(len(tags), 1)
self.assertEqual(tags, {'foo': 'bar'})
def test_pinpoint_app_remove_tag(self):
session_factory = self.replay_flight_data('test_pinpoint_app_remove_tag')
p = self.load_policy(
{
'name': 'test-pinpoint-app-remove-tag',
'resource': 'pinpoint-app',
'filters': [
{
'tag:foo': 'present',
}
],
'actions': [
{
'type': 'remove-tag',
'tags': ['foo']
}
]
}, session_factory=session_factory
)
resources = p.run()
self.assertEqual(len(resources), 1)
client = session_factory().client('pinpoint')
tags = client.list_tags_for_resource(ResourceArn=resources[0]['Arn'])['TagsModel']['tags']
self.assertEqual(len(tags), 0)