Пример #1
0
def test_record(mock_store):
    """Passes notification data on to ``store``."""
    record._record(
        _profile(id=2), 'some', triggering=False, data={'foo': 'bar'})

    mock_store.assert_called_with(
        2, 'some', triggering=False, data={'foo': 'bar'})
Пример #2
0
def test_record_triggering(mock_store):
    """If triggering, triggers send_notification task."""
    tgt = 'portfoliyo.notifications.record.tasks.send_notification_email.delay'
    with mock.patch(tgt) as mock_task_delay:
        record._record(_profile(id=2), 'some', triggering=True)

    mock_task_delay.assert_called_with(2)
    mock_store.assert_called_with(2, 'some', triggering=True, data=None)
Пример #3
0
def test_record_triggering(mock_store):
    """If triggering, triggers send_notification task."""
    tgt = 'portfoliyo.notifications.record.tasks.send_notification_email.delay'
    with mock.patch(tgt) as mock_task_delay:
        record._record(_profile(id=2), 'some', triggering=True)

    mock_task_delay.assert_called_with(2)
    mock_store.assert_called_with(
        2, 'some', triggering=True, data=None)
Пример #4
0
def test_record_triggering_disabled(mock_store):
    """If NOTIFICATION_EMAILS setting is ``False``, no email sent."""
    settings_tgt = 'portfoliyo.notifications.record.settings'
    tgt = 'portfoliyo.notifications.record.tasks.send_notification_email.delay'
    with mock.patch(settings_tgt) as mock_settings:
        with mock.patch(tgt) as mock_task_delay:
            mock_settings.NOTIFICATION_EMAILS = False
            record._record(_profile(id=2), 'some', triggering=True)

    assert mock_task_delay.call_count == 0
Пример #5
0
def test_record_triggering_disabled(mock_store):
    """If NOTIFICATION_EMAILS setting is ``False``, no email sent."""
    settings_tgt = 'portfoliyo.notifications.record.settings'
    tgt = 'portfoliyo.notifications.record.tasks.send_notification_email.delay'
    with mock.patch(settings_tgt) as mock_settings:
        with mock.patch(tgt) as mock_task_delay:
            mock_settings.NOTIFICATION_EMAILS = False
            record._record(_profile(id=2), 'some', triggering=True)

    assert mock_task_delay.call_count == 0
Пример #6
0
def test_record(mock_store):
    """Passes notification data on to ``store``."""
    record._record(_profile(id=2),
                   'some',
                   triggering=False,
                   data={'foo': 'bar'})

    mock_store.assert_called_with(2,
                                  'some',
                                  triggering=False,
                                  data={'foo': 'bar'})
Пример #7
0
def test_record_doesnt_store_if_no_email(mock_store):
    """Doesn't store notifications for users without email addresses."""
    record._record(_profile(id=2, email=None), 'some')

    assert not mock_store.call_count
Пример #8
0
def test_record_doesnt_store_if_user_inactive(mock_store):
    """Doesn't store notifications for inactive users."""
    record._record(_profile(id=2, is_active=False), 'some')

    assert not mock_store.call_count
Пример #9
0
def test_record_doesnt_store_if_no_email(mock_store):
    """Doesn't store notifications for users without email addresses."""
    record._record(_profile(id=2, email=None), 'some')

    assert not mock_store.call_count
Пример #10
0
def test_record_doesnt_store_if_user_inactive(mock_store):
    """Doesn't store notifications for inactive users."""
    record._record(_profile(id=2, is_active=False), 'some')

    assert not mock_store.call_count