本文整理汇总了Python中awslimitchecker.limit.AwsLimit类的典型用法代码示例。如果您正苦于以下问题:Python AwsLimit类的具体用法?Python AwsLimit怎么用?Python AwsLimit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AwsLimit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_thresholds
def test_get_thresholds(self):
limit = AwsLimit('limitname', self.mock_svc, 100, 1, 2)
assert limit._get_thresholds() == (
None,
1,
None,
2
)
示例2: test_get_current_usage_str_none
def test_get_current_usage_str_none(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
assert limit.get_current_usage_str() == '<unknown>'
示例3: test_get_current_usage
def test_get_current_usage(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
limit._current_usage = 2
assert limit.get_current_usage() == 2
示例4: test_get_current_usage_str
def test_get_current_usage_str(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
limit._add_current_usage(4)
assert limit.get_current_usage_str() == '4'
示例5: test_get_current_usage_str_id
def test_get_current_usage_str_id(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
limit._add_current_usage(4, resource_id='foobar')
assert limit.get_current_usage_str() == 'foobar=4'
示例6: test_set_api_limit
def test_set_api_limit(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
assert limit.api_limit is None
limit._set_api_limit(10)
assert limit.api_limit == 10
示例7: test_set_limit_override_ta_False
def test_set_limit_override_ta_False(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
limit.set_limit_override(1, override_ta=False)
assert limit.limit_override == 1
assert limit.default_limit == 3
assert limit.override_ta is False
示例8: test_set_limit_override
def test_set_limit_override(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
limit.set_limit_override(10)
assert limit.limit_override == 10
assert limit.default_limit == 3
assert limit.override_ta is True
示例9: test_set_threshold_override
def test_set_threshold_override(self):
limit = AwsLimit('limitname', self.mock_svc, 100, 1, 2)
limit.set_threshold_override(
warn_percent=1,
warn_count=2,
crit_percent=3,
crit_count=4
)
assert limit.warn_percent == 1
assert limit.warn_count == 2
assert limit.crit_percent == 3
assert limit.crit_count == 4
示例10: test_set_ta_unlimited
def test_set_ta_unlimited(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
assert limit.ta_limit is None
assert limit.ta_unlimited is False
limit._set_ta_unlimited()
assert limit.ta_limit is None
assert limit.ta_unlimited is True
示例11: test_check_thresholds_pct_warn_crit
def test_check_thresholds_pct_warn_crit(self):
limit = AwsLimit('limitname', self.mock_svc, 100, 1, 2)
u1 = AwsLimitUsage(limit, 50, resource_id='foo4bar')
u2 = AwsLimitUsage(limit, 3, resource_id='foo3bar')
u3 = AwsLimitUsage(limit, 95, resource_id='foo2bar')
limit._current_usage = [u1, u2, u3]
with patch('awslimitchecker.limit.AwsLimit.'
'_get_thresholds') as mock_get_thresh:
with patch('awslimitchecker.limit.AwsLimit.get_'
'limit') as mock_get_limit:
mock_get_thresh.return_value = (None, 40, None, 80)
mock_get_limit.return_value = 100
res = limit.check_thresholds()
assert res is False
assert limit._warnings == [u1]
assert limit._criticals == [u3]
assert mock_get_thresh.mock_calls == [call()]
assert mock_get_limit.mock_calls == [call()]
示例12: test_check_thresholds_ta_unlimited
def test_check_thresholds_ta_unlimited(self):
limit = AwsLimit('limitname', self.mock_svc, 3, 1, 2)
u1 = AwsLimitUsage(limit, 4, resource_id='foo4bar')
u2 = AwsLimitUsage(limit, 3, resource_id='foo3bar')
u3 = AwsLimitUsage(limit, 2, resource_id='foo2bar')
limit._current_usage = [u1, u2, u3]
limit._set_ta_unlimited()
with patch('awslimitchecker.limit.AwsLimit.'
'_get_thresholds') as mock_get_thresh:
with patch('awslimitchecker.limit.AwsLimit.get_'
'limit') as mock_get_limit:
mock_get_thresh.return_value = (None, 40, None, 80)
mock_get_limit.return_value = None
res = limit.check_thresholds()
assert res is True
assert limit._warnings == []
assert limit._criticals == []
assert mock_get_thresh.mock_calls == []
assert mock_get_limit.mock_calls == [call()]
示例13: test_add_current_usage
def test_add_current_usage(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
assert limit._current_usage == []
limit._add_current_usage(2)
assert len(limit.get_current_usage()) == 1
assert limit._current_usage[0].get_value() == 2
limit._add_current_usage(4)
assert len(limit.get_current_usage()) == 2
assert limit._current_usage[1].get_value() == 4
示例14: test_get_thresholds_overridden
def test_get_thresholds_overridden(self):
limit = AwsLimit('limitname', self.mock_svc, 100, 88, 99)
limit.warn_percent = 1
limit.warn_count = 2
limit.crit_percent = 3
limit.crit_count = 4
assert limit._get_thresholds() == (
2,
1,
4,
3
)
示例15: test_get_current_usage_str_multi
def test_get_current_usage_str_multi(self):
limit = AwsLimit(
'limitname',
self.mock_svc,
3,
1,
2
)
limit._add_current_usage(4)
limit._add_current_usage(3)
limit._add_current_usage(2)
assert limit.get_current_usage_str() == 'max: 4 (2, 3, 4)'