Beispiel #1
0
def test_get_pusher(mock_Pusher):
    """If settings are configured, returns a Pusher instance."""
    with override_settings(PUSHER_APPID='a', PUSHER_KEY='k', PUSHER_SECRET='s'):
        p = pusher.get_pusher()

    assert p is mock_Pusher.return_value
    mock_Pusher.assert_called_with(app_id='a', key='k', secret='s', port=443)
Beispiel #2
0
def test_get_pusher(mock_Pusher):
    """If settings are configured, returns a Pusher instance."""
    with override_settings(PUSHER_APPID='a', PUSHER_KEY='k',
                           PUSHER_SECRET='s'):
        p = pusher.get_pusher()

    assert p is mock_Pusher.return_value
    mock_Pusher.assert_called_with(app_id='a', key='k', secret='s', port=443)
def trigger(channel, event, data):
    """
    Fire ``event`` on ``channel`` with ``data`` if Pusher is configured.

    Log failures, but never blow up.

    """
    pusher = get_pusher()
    if pusher is None:
        return
    try:
        pusher['private-%s' % channel].trigger(event, data)
    except Exception as e:
        logger.warning(
            "Pusher exception: %s" % str(e),
            exc_info=True,
            extra={'stack': True},
        )
Beispiel #4
0
def trigger(channel, event, data):
    """
    Fire ``event`` on ``channel`` with ``data`` if Pusher is configured.

    Log failures, but never blow up.

    """
    pusher = get_pusher()
    if pusher is None:
        return
    try:
        pusher['private-%s' % channel].trigger(event, data)
    except Exception as e:
        logger.warning(
            "Pusher exception: %s" % str(e),
            exc_info=True,
            extra={'stack': True},
            )
Beispiel #5
0
def test_get_pusher_none():
    """If settings are not configured, return None."""
    assert pusher.get_pusher() is None
Beispiel #6
0
def test_get_pusher_none():
    """If settings are not configured, return None."""
    assert pusher.get_pusher() is None