Beispiel #1
0
def test_process_external(find_event):
    core.cleanup_handlers()

    handler = Mock()
    eventlib.external_handler('app.Event')(handler)

    data = {'file': '/etc/passwd', 'server': 'yipster'}
    core.process_external('app.Event', data)

    handler.assert_called_once_with(data)
Beispiel #2
0
def test_process_external(find_event):
    core.cleanup_handlers()

    handler = Mock()
    eventlib.external_handler('app.Event')(handler)

    data = {'file': '/etc/passwd', 'server': 'yipster'}
    core.process_external('app.Event', data)

    handler.assert_called_once_with(data)
Beispiel #3
0
def test_process_external_raises_the_exception_when_debugging(
        settings, find_event):
    core.cleanup_handlers()
    settings.DEBUG = True

    handler_fail = Mock()
    handler_fail.side_effect = ValueError('P0wned!!!')
    eventlib.external_handler('myapp.CoolEvent')(handler_fail)
    name, data = 'myapp.CoolEvent', {'a': 1}
    core.process_external.when.called_with(name, data).should.throw(
        ValueError, 'P0wned!!!')
Beispiel #4
0
def test_process_external_raises_the_exception_when_debugging(
        settings, find_event):
    core.cleanup_handlers()
    settings.DEBUG = True

    handler_fail = Mock()
    handler_fail.side_effect = ValueError('P0wned!!!')
    eventlib.external_handler('myapp.CoolEvent')(handler_fail)
    name, data = 'myapp.CoolEvent', {'a': 1}
    core.process_external.when.called_with(name, data).should.throw(
        ValueError, 'P0wned!!!')
Beispiel #5
0
def test_process_external_fails_gracefully(settings, logger, find_event):
    core.cleanup_handlers()
    settings.DEBUG = False

    handler_fail = Mock()
    handler_fail.side_effect = ValueError('P0wned!!!')
    eventlib.external_handler('myapp.CoolEvent')(handler_fail)

    handler = Mock()
    eventlib.external_handler('myapp.CoolEvent')(handler)

    data = {'a': 1}
    event = 'myapp.CoolEvent'
    core.process_external(event, data)

    logger.warning.assert_called_once_with(
        'One of the handlers for the event "myapp.CoolEvent" has '
        'failed with the following exception: P0wned!!!')
    handler.assert_called_once_with(data)
Beispiel #6
0
def test_process_external_fails_gracefully(settings, logger, find_event):
    core.cleanup_handlers()
    settings.DEBUG = False

    handler_fail = Mock()
    handler_fail.side_effect = ValueError('P0wned!!!')
    eventlib.external_handler('myapp.CoolEvent')(handler_fail)

    handler = Mock()
    eventlib.external_handler('myapp.CoolEvent')(handler)

    data = {'a': 1}
    event = 'myapp.CoolEvent'
    core.process_external(event, data)

    logger.warning.assert_called_once_with(
        'One of the handlers for the event "myapp.CoolEvent" has '
        'failed with the following exception: P0wned!!!')
    handler.assert_called_once_with(data)