Пример #1
0
def test_mark_announcement_read(no_csrf_client):
    p = factories.ProfileFactory.create(user__email='*****@*****.**')
    a = announce.to_all('something')

    assert list(announce.get_unread(p)) == [a]

    no_csrf_client.post(
        reverse('mark_announcement_read', kwargs={'annc_id': a.id}),
        user=p.user,
        )

    assert list(announce.get_unread(p)) == []
Пример #2
0
def test_mark_announcement_read(no_csrf_client):
    p = factories.ProfileFactory.create(user__email='*****@*****.**')
    a = announce.to_all('something')

    assert list(announce.get_unread(p)) == [a]

    no_csrf_client.post(
        reverse('mark_announcement_read', kwargs={'annc_id': a.id}),
        user=p.user,
    )

    assert list(announce.get_unread(p)) == []
Пример #3
0
def test_read_unread(db, redis):
    """Test announce_to_all, get_unread_announcements, mark_read_by."""
    p1 = factories.ProfileFactory.create(user__email='*****@*****.**')
    p2 = factories.ProfileFactory.create(user__email='*****@*****.**')
    p3 = factories.ProfileFactory.create(user__email=None)

    a1 = announce.to_all("Something is happening!")
    a2 = announce.to_all("Something else is happening!")

    assert list(announce.get_unread(p1)) == [a1, a2]
    assert list(announce.get_unread(p2)) == [a1, a2]
    assert list(announce.get_unread(p3)) == []

    announce.mark_read(p1, a1.id)

    assert list(announce.get_unread(p1)) == [a2]
    assert list(announce.get_unread(p2)) == [a1, a2]
Пример #4
0
def test_read_unread(db, redis):
    """Test announce_to_all, get_unread_announcements, mark_read_by."""
    p1 = factories.ProfileFactory.create(user__email='*****@*****.**')
    p2 = factories.ProfileFactory.create(user__email='*****@*****.**')
    p3 = factories.ProfileFactory.create(user__email=None)

    a1 = announce.to_all("Something is happening!")
    a2 = announce.to_all("Something else is happening!")

    assert list(announce.get_unread(p1)) == [a1, a2]
    assert list(announce.get_unread(p2)) == [a1, a2]
    assert list(announce.get_unread(p3)) == []

    announce.mark_read(p1, a1.id)

    assert list(announce.get_unread(p1)) == [a2]
    assert list(announce.get_unread(p2)) == [a1, a2]
Пример #5
0
def unread_announcements(profile):
    return announce.get_unread(profile)