Beispiel #1
0
def test_pending_profile_ids(redis):
    """Includes profile IDs with triggering notifications."""
    store.store(1, 'some', triggering=True)
    store.store(1, 'other', triggering=False)
    store.store(2, 'thing', triggering=False)
    store.store(3, 'thing', triggering=True)

    assert store.pending_profile_ids() == {'1', '3'}
def test_pending_profile_ids(redis):
    """Includes profile IDs with triggering notifications."""
    store.store(1, 'some', triggering=True)
    store.store(1, 'other', triggering=False)
    store.store(2, 'thing', triggering=False)
    store.store(3, 'thing', triggering=True)

    assert store.pending_profile_ids() == {'1', '3'}
Beispiel #3
0
def test_get_all_clear(redis):
    """Can also clear all pending notifications."""
    store.store(1, 'some', data={'foo': 'bar'})
    store.store(1, 'other', triggering=True)
    store.store(2, 'irrelevant')

    res = list(store.get_all(1, clear=True))

    assert res == [
        {'name': 'some', 'triggering': '0', 'foo': 'bar'},
        {'name': 'other', 'triggering': '1'},
        ]

    # clears
    assert list(store.get_all(1)) == []
    assert store.pending_profile_ids() == set()
Beispiel #4
0
def test_get_all(redis):
    """Gets all data from all pending notifications."""
    store.store(1, 'some', data={'foo': 'bar'})
    store.store(1, 'other', triggering=True)
    store.store(2, 'irrelevant')

    res = list(store.get_all(1))

    assert res == [
        {'name': 'some', 'triggering': '0', 'foo': 'bar'},
        {'name': 'other', 'triggering': '1'},
        ]

    # does not clear by default
    assert list(store.get_all(1)) == res
    assert store.pending_profile_ids() == set(['1'])
def test_get_all_clear(redis):
    """Can also clear all pending notifications."""
    store.store(1, 'some', data={'foo': 'bar'})
    store.store(1, 'other', triggering=True)
    store.store(2, 'irrelevant')

    res = list(store.get_all(1, clear=True))

    assert res == [
        {
            'name': 'some',
            'triggering': '0',
            'foo': 'bar'
        },
        {
            'name': 'other',
            'triggering': '1'
        },
    ]

    # clears
    assert list(store.get_all(1)) == []
    assert store.pending_profile_ids() == set()
def test_get_all(redis):
    """Gets all data from all pending notifications."""
    store.store(1, 'some', data={'foo': 'bar'})
    store.store(1, 'other', triggering=True)
    store.store(2, 'irrelevant')

    res = list(store.get_all(1))

    assert res == [
        {
            'name': 'some',
            'triggering': '0',
            'foo': 'bar'
        },
        {
            'name': 'other',
            'triggering': '1'
        },
    ]

    # does not clear by default
    assert list(store.get_all(1)) == res
    assert store.pending_profile_ids() == set(['1'])
Beispiel #7
0
def check_for_pending_notifications():
    """Trigger notifications to all users with pending notifications."""
    from portfoliyo.notifications import store
    for profile_id in store.pending_profile_ids():
        send_notification_email.delay(profile_id)