def test_find_usage_spot_instances(self): data = fixtures.test_find_usage_spot_instances mock_conn = Mock() mock_client_conn = Mock() mock_client_conn.describe_spot_instance_requests.return_value = data cls = _Ec2Service(21, 43) cls.resource_conn = mock_conn cls.conn = mock_client_conn with patch('awslimitchecker.services.ec2.logger') as mock_logger: cls._find_usage_spot_instances() assert mock_conn.mock_calls == [] assert mock_client_conn.mock_calls == [ call.describe_spot_instance_requests() ] lim = cls.limits['Max spot instance requests per region'] usage = lim.get_current_usage() assert len(usage) == 1 assert usage[0].get_value() == 2 assert mock_logger.mock_calls == [ call.debug('Getting spot instance request usage'), call.debug('NOT counting spot instance request %s state=%s', 'reqID1', 'closed'), call.debug('Counting spot instance request %s state=%s', 'reqID2', 'active'), call.debug('Counting spot instance request %s state=%s', 'reqID3', 'open'), call.debug('NOT counting spot instance request %s state=%s', 'reqID4', 'failed') ]
def test_find_usage_spot_instances(self): data = fixtures.test_find_usage_spot_instances mock_conn = Mock() mock_client_conn = Mock() mock_client_conn.describe_spot_instance_requests.return_value = data cls = _Ec2Service(21, 43) cls.resource_conn = mock_conn cls.conn = mock_client_conn with patch('awslimitchecker.services.ec2.logger') as mock_logger: cls._find_usage_spot_instances() assert mock_conn.mock_calls == [] assert mock_client_conn.mock_calls == [ call.describe_spot_instance_requests() ] lim = cls.limits['Max spot instance requests per region'] usage = lim.get_current_usage() assert len(usage) == 1 assert usage[0].get_value() == 2 assert mock_logger.mock_calls == [ call.debug('Getting spot instance request usage'), call.warning('EC2 spot instance support is experimental and ' 'results may not me accurate in all cases. Please ' 'see the notes at: <http://awslimitchecker' '.readthedocs.io/en/latest/limits.html#ec2>'), call.debug('NOT counting spot instance request %s state=%s', 'reqID1', 'closed'), call.debug('Counting spot instance request %s state=%s', 'reqID2', 'active'), call.debug('Counting spot instance request %s state=%s', 'reqID3', 'open'), call.debug('NOT counting spot instance request %s state=%s', 'reqID4', 'failed'), call.debug('Setting "Max spot instance requests per region" ' 'limit (%s) current usage to: %d', lim, 2) ]
def test_find_usage_spot_instances(self): data = fixtures.test_find_usage_spot_instances mock_conn = Mock() mock_client_conn = Mock() mock_client_conn.describe_spot_instance_requests.return_value = data cls = _Ec2Service(21, 43) cls.resource_conn = mock_conn cls.conn = mock_client_conn with patch('awslimitchecker.services.ec2.logger') as mock_logger: cls._find_usage_spot_instances() assert mock_conn.mock_calls == [] assert mock_client_conn.mock_calls == [ call.describe_spot_instance_requests() ] lim = cls.limits['Max spot instance requests per region'] usage = lim.get_current_usage() assert len(usage) == 1 assert usage[0].get_value() == 2 assert mock_logger.mock_calls == [ call.debug('Getting spot instance request usage'), call.warning('EC2 spot instance support is experimental and ' 'results may not me accurate in all cases. Please ' 'see the notes at: <http://awslimitchecker' '.readthedocs.io/en/latest/limits.html#ec2>'), call.debug('NOT counting spot instance request %s state=%s', 'reqID1', 'closed'), call.debug('Counting spot instance request %s state=%s', 'reqID2', 'active'), call.debug('Counting spot instance request %s state=%s', 'reqID3', 'open'), call.debug('NOT counting spot instance request %s state=%s', 'reqID4', 'failed'), call.debug( 'Setting "Max spot instance requests per region" ' 'limit (%s) current usage to: %d', lim, 2) ]