14
14
15
15
from botocore .stub import Stubber
16
16
17
- ACCOUNT_ID = "123412341234"
18
17
RESOURCE_TYPE = "Aa::Bb::Cc"
19
18
NAMESPACE = MetricsPublisherProxy ._make_namespace ( # pylint: disable=protected-access
20
- ACCOUNT_ID , RESOURCE_TYPE
19
+ RESOURCE_TYPE
21
20
)
22
21
23
22
@@ -74,13 +73,13 @@ def test_put_metric_catches_error(mock_session):
74
73
75
74
def test_publish_exception_metric (mock_session ):
76
75
fake_datetime = datetime (2019 , 1 , 1 )
77
- proxy = MetricsPublisherProxy (ACCOUNT_ID , RESOURCE_TYPE )
76
+ proxy = MetricsPublisherProxy (RESOURCE_TYPE )
78
77
proxy .add_metrics_publisher (mock_session )
79
78
proxy .publish_exception_metric (fake_datetime , Action .CREATE , Exception ("fake-err" ))
80
79
expected_calls = [
81
80
call .client ("cloudwatch" ),
82
81
call .client ().put_metric_data (
83
- Namespace = "AWS/CloudFormation/123412341234/ Aa/Bb/Cc" ,
82
+ Namespace = "AWS/CloudFormation/Aa/Bb/Cc" ,
84
83
MetricData = [
85
84
{
86
85
"MetricName" : MetricTypes .HandlerException .name ,
@@ -104,14 +103,14 @@ def test_publish_exception_metric(mock_session):
104
103
105
104
def test_publish_invocation_metric (mock_session ):
106
105
fake_datetime = datetime (2019 , 1 , 1 )
107
- proxy = MetricsPublisherProxy (ACCOUNT_ID , RESOURCE_TYPE )
106
+ proxy = MetricsPublisherProxy (RESOURCE_TYPE )
108
107
proxy .add_metrics_publisher (mock_session )
109
108
proxy .publish_invocation_metric (fake_datetime , Action .CREATE )
110
109
111
110
expected_calls = [
112
111
call .client ("cloudwatch" ),
113
112
call .client ().put_metric_data (
114
- Namespace = "AWS/CloudFormation/123412341234/ Aa/Bb/Cc" ,
113
+ Namespace = "AWS/CloudFormation/Aa/Bb/Cc" ,
115
114
MetricData = [
116
115
{
117
116
"MetricName" : MetricTypes .HandlerInvocationCount .name ,
@@ -131,14 +130,14 @@ def test_publish_invocation_metric(mock_session):
131
130
132
131
def test_publish_duration_metric (mock_session ):
133
132
fake_datetime = datetime (2019 , 1 , 1 )
134
- proxy = MetricsPublisherProxy (ACCOUNT_ID , RESOURCE_TYPE )
133
+ proxy = MetricsPublisherProxy (RESOURCE_TYPE )
135
134
proxy .add_metrics_publisher (mock_session )
136
135
proxy .publish_duration_metric (fake_datetime , Action .CREATE , 100 )
137
136
138
137
expected_calls = [
139
138
call .client ("cloudwatch" ),
140
139
call .client ().put_metric_data (
141
- Namespace = "AWS/CloudFormation/123412341234/ Aa/Bb/Cc" ,
140
+ Namespace = "AWS/CloudFormation/Aa/Bb/Cc" ,
142
141
MetricData = [
143
142
{
144
143
"MetricName" : MetricTypes .HandlerInvocationDuration .name ,
@@ -158,14 +157,14 @@ def test_publish_duration_metric(mock_session):
158
157
159
158
def test_publish_log_delivery_exception_metric (mock_session ):
160
159
fake_datetime = datetime (2019 , 1 , 1 )
161
- proxy = MetricsPublisherProxy (ACCOUNT_ID , RESOURCE_TYPE )
160
+ proxy = MetricsPublisherProxy (RESOURCE_TYPE )
162
161
proxy .add_metrics_publisher (mock_session )
163
162
proxy .publish_log_delivery_exception_metric (fake_datetime , TypeError ("test" ))
164
163
165
164
expected_calls = [
166
165
call .client ("cloudwatch" ),
167
166
call .client ().put_metric_data (
168
- Namespace = "AWS/CloudFormation/123412341234/ Aa/Bb/Cc" ,
167
+ Namespace = "AWS/CloudFormation/Aa/Bb/Cc" ,
169
168
MetricData = [
170
169
{
171
170
"MetricName" : MetricTypes .HandlerException .name ,
@@ -191,6 +190,6 @@ def test_publish_log_delivery_exception_metric(mock_session):
191
190
192
191
193
192
def test_metrics_publisher_proxy_add_metrics_publisher_none_safe ():
194
- proxy = MetricsPublisherProxy (ACCOUNT_ID , RESOURCE_TYPE )
193
+ proxy = MetricsPublisherProxy (RESOURCE_TYPE )
195
194
proxy .add_metrics_publisher (None )
196
195
assert proxy ._publishers == [] # pylint: disable=protected-access
0 commit comments