'Test the private method _send_audit_notification with opt-out.
Test that _send_audit_notification does not notify when a valid
notification_opt_out configuration is provided.'

def test_send_audit_notification_with_opt_out(self):

    resource_type = EXP_RESOURCE_TYPE
    action = ((CREATED_OPERATION + '.') + resource_type)
    initiator = mock
    target = mock
    outcome = 'success'
    event_type = ('identity.%s.created' % resource_type)
    conf = self.useFixture(config_fixture.Config(CONF))
    conf.config(notification_opt_out=[event_type])
    with mock.patch.object(notifications._get_notifier(), '_notify') as mocked:
        notifications._send_audit_notification(action, initiator, outcome, target, event_type)
        mocked.assert_not_called()
