@mock.patch('oslo_limit.limit.Enforcer')
def test_enforce_num_instances_and_flavor_retry(self, mock_limit):
    mock_enforcer = mock.MagicMock()
    mock_limit.return_value = mock_enforcer
    over_limit_info_list = [limit_exceptions.OverLimitInfo('class:VCPU', 12, 0, 30)]
    mock_enforcer.enforce.side_effect = [limit_exceptions.ProjectOverLimit(uuids.project_id, over_limit_info_list), None]
    count = placement_limits.enforce_num_instances_and_flavor(self.context, uuids.project_id, self.flavor, True, 0, 3)
    self.assertEqual(2, count)
    self.assertEqual(2, mock_enforcer.enforce.call_count)
    mock_enforcer.enforce.assert_called_with(uuids.project_id, {'servers': 2, 'class:VCPU': 20, 'class:MEMORY_MB': 200, 'class:DISK_GB': 4})
@mock.patch('oslo_limit.limit.Enforcer')
def test_enforce_num_instances_and_flavor_retry(self, mock_limit):
    mock_enforcer = mock.MagicMock()
    mock_limit.return_value = mock_enforcer
    over_limit_info_list = [limit_exceptions.OverLimitInfo('class:VCPU', 12, 0, 30)]
    mock_enforcer.enforce.side_effect = [limit_exceptions.ProjectOverLimit(uuids.project_id, over_limit_info_list), None]
    count = placement_limits.enforce_num_instances_and_flavor(self.context, uuids.project_id, self.flavor, True, 0, 3)
    self.assertEqual(2, count)
    self.assertEqual(2, mock_enforcer.enforce.call_count)
    mock_enforcer.enforce.assert_called_with(uuids.project_id, {'servers': 2, 'class:VCPU': 20, 'class:MEMORY_MB': 200, 'class:DISK_GB': 4})