Пример #1
0
 def test_get_limits_again(self):
     """test that existing limits dict is returned on subsequent calls"""
     mock_limits = Mock(spec_set=AwsLimit)
     cls = _S3Service(21, 43)
     cls.limits = mock_limits
     res = cls.get_limits()
     assert res == mock_limits
Пример #2
0
 def test_get_limits_again(self):
     """test that existing limits dict is returned on subsequent calls"""
     mock_limits = Mock(spec_set=AwsLimit)
     cls = _S3Service(21, 43)
     cls.limits = mock_limits
     res = cls.get_limits()
     assert res == mock_limits
Пример #3
0
 def test_init(self):
     """test __init__()"""
     cls = _S3Service(21, 43)
     assert cls.service_name == 'S3'
     assert cls.api_name == 's3'
     assert cls.conn is None
     assert cls.warning_threshold == 21
     assert cls.critical_threshold == 43
Пример #4
0
 def test_init(self):
     """test __init__()"""
     cls = _S3Service(21, 43)
     assert cls.service_name == 'S3'
     assert cls.api_name == 's3'
     assert cls.conn is None
     assert cls.warning_threshold == 21
     assert cls.critical_threshold == 43
Пример #5
0
 def test_get_limits(self):
     cls = _S3Service(21, 43)
     cls.limits = {}
     res = cls.get_limits()
     assert sorted(res.keys()) == sorted([
         'Buckets',
     ])
     assert res['Buckets'].service == cls
     assert res['Buckets'].def_warning_threshold == 21
     assert res['Buckets'].def_critical_threshold == 43
     assert res['Buckets'].default_limit == 100
Пример #6
0
 def test_get_limits(self):
     cls = _S3Service(21, 43)
     cls.limits = {}
     res = cls.get_limits()
     assert sorted(res.keys()) == sorted([
         'Buckets',
     ])
     assert res['Buckets'].service == cls
     assert res['Buckets'].def_warning_threshold == 21
     assert res['Buckets'].def_critical_threshold == 43
     assert res['Buckets'].default_limit == 100
Пример #7
0
 def test_find_usage(self):
     mock_buckets = Mock()
     mock_buckets.all.return_value = ['a', 'b', 'c']
     mock_conn = Mock(buckets=mock_buckets)
     with patch('%s.connect_resource' % pb) as mock_connect:
         cls = _S3Service(21, 43)
         cls.resource_conn = mock_conn
         assert cls._have_usage is False
         cls.find_usage()
     assert mock_connect.mock_calls == [call()]
     assert cls._have_usage is True
     assert mock_buckets.mock_calls == [call.all()]
     assert len(cls.limits['Buckets'].get_current_usage()) == 1
     assert cls.limits['Buckets'].get_current_usage()[0].get_value() == 3
Пример #8
0
 def test_find_usage(self):
     mock_buckets = Mock()
     mock_buckets.all.return_value = ['a', 'b', 'c']
     mock_conn = Mock(buckets=mock_buckets)
     with patch('%s.connect_resource' % pb) as mock_connect:
         cls = _S3Service(21, 43)
         cls.resource_conn = mock_conn
         assert cls._have_usage is False
         cls.find_usage()
     assert mock_connect.mock_calls == [call()]
     assert cls._have_usage is True
     assert mock_buckets.mock_calls == [call.all()]
     assert len(cls.limits['Buckets'].get_current_usage()) == 1
     assert cls.limits['Buckets'].get_current_usage()[0].get_value() == 3
Пример #9
0
 def test_required_iam_permissions(self):
     cls = _S3Service(21, 43)
     assert cls.required_iam_permissions() == ['s3:ListAllMyBuckets']
Пример #10
0
 def test_required_iam_permissions(self):
     cls = _S3Service(21, 43)
     assert cls.required_iam_permissions() == [
         's3:ListAllMyBuckets'
     ]