def test_find_usage_security_groups(self):
        """test find usage for security groups"""
        data = {
            'DescribeCacheSecurityGroupsResponse': {
                'DescribeCacheSecurityGroupsResult': {
                    'Marker': None,
                    'CacheSecurityGroups': [
                        {
                            'OwnerId': '123456789012',
                            'CacheSecurityGroupName': 'default',
                            'Description': 'default',
                            'EC2SecurityGroups': []
                        },
                        {
                            'OwnerId': '123456789012',
                            'CacheSecurityGroupName': 'csg1',
                            'Description': 'foo bar',
                            'EC2SecurityGroups': [
                                {
                                    'EC2SecurityGroupName': 'ec2-sg1',
                                    'Status': 'authorized',
                                    'EC2SecurityGroupOwnerId': '123456789012'
                                }
                            ]
                        }
                    ]
                },
                'ResponseMetadata': {
                    'RequestId': 'be15fa9c-26ac-11e5-a849-894e77ed58a8'
                }
            }
        }

        mock_conn = Mock(spec_set=ElastiCacheConnection)
        mock_conn.describe_cache_security_groups.return_value = data
        cls = _ElastiCacheService(21, 43)
        cls.conn = mock_conn
        cls._find_usage_security_groups()

        assert mock_conn.mock_calls == [
            call.describe_cache_security_groups(),
        ]

        usage = cls.limits['Security Groups'].get_current_usage()
        assert len(usage) == 1
        assert usage[0].get_value() == 2
    def test_find_usage_security_groups_exception(self):
        """test find usage for security groups"""
        def se_exc():
            raise BotoServerError(None, None, None)

        mock_conn = Mock(spec_set=ElastiCacheConnection)
        mock_conn.describe_cache_security_groups.side_effect = se_exc
        cls = _ElastiCacheService(21, 43)
        cls.conn = mock_conn
        cls._find_usage_security_groups()

        assert mock_conn.mock_calls == [
            call.describe_cache_security_groups(),
        ]

        usage = cls.limits['Security Groups'].get_current_usage()
        assert len(usage) == 1
        assert usage[0].get_value() == 0