@mock.patch('oslo_limit.limit.Enforcer')
def test_enforce_num_instances_and_flavor_fails(self, mock_limit):
    mock_enforcer = mock.MagicMock()
    mock_limit.return_value = mock_enforcer
    over_limit_info_list = [limit_exceptions.OverLimitInfo('class:VCPU', 12, 0, 20), limit_exceptions.OverLimitInfo('servers', 2, 1, 2)]
    expected = limit_exceptions.ProjectOverLimit(uuids.project_id, over_limit_info_list)
    mock_enforcer.enforce.side_effect = expected
    e = self.assertRaises(exception.TooManyInstances, placement_limits.enforce_num_instances_and_flavor, self.context, uuids.project_id, self.flavor, True, 2, 4)
    self.assertEqual(str(expected), str(e))
    self.assertEqual(3, mock_enforcer.enforce.call_count)
@mock.patch('oslo_limit.limit.Enforcer')
def test_enforce_num_instances_and_flavor_fails(self, mock_limit):
    mock_enforcer = mock.MagicMock()
    mock_limit.return_value = mock_enforcer
    over_limit_info_list = [limit_exceptions.OverLimitInfo('class:VCPU', 12, 0, 20), limit_exceptions.OverLimitInfo('servers', 2, 1, 2)]
    expected = limit_exceptions.ProjectOverLimit(uuids.project_id, over_limit_info_list)
    mock_enforcer.enforce.side_effect = expected
    e = self.assertRaises(exception.TooManyInstances, placement_limits.enforce_num_instances_and_flavor, self.context, uuids.project_id, self.flavor, True, 2, 4)
    self.assertEqual(str(expected), str(e))
    self.assertEqual(3, mock_enforcer.enforce.call_count)