@mock.patch('oslo_limit.limit.Enforcer')
def test_enforce_num_instances_and_flavor_placement_fail(self, mock_limit):
    mock_enforcer = mock.MagicMock()
    mock_limit.return_value = mock_enforcer
    mock_enforcer.enforce.side_effect = exception.UsagesRetrievalFailed('Failed to retrieve usages')
    e = self.assertRaises(exception.UsagesRetrievalFailed, placement_limits.enforce_num_instances_and_flavor, self.context, uuids.project, self.flavor, True, 0, 5)
    expected = str(mock_enforcer.enforce.side_effect)
    self.assertEqual(expected, str(e))
@mock.patch('oslo_limit.limit.Enforcer')
def test_enforce_num_instances_and_flavor_placement_fail(self, mock_limit):
    mock_enforcer = mock.MagicMock()
    mock_limit.return_value = mock_enforcer
    mock_enforcer.enforce.side_effect = exception.UsagesRetrievalFailed('Failed to retrieve usages')
    e = self.assertRaises(exception.UsagesRetrievalFailed, placement_limits.enforce_num_instances_and_flavor, self.context, uuids.project, self.flavor, True, 0, 5)
    expected = str(mock_enforcer.enforce.side_effect)
    self.assertEqual(expected, str(e))