예제 #1
0
def test_delete_conversation(app, authed_client):
    add_permissions(app, MessagePermissions.VIEW_DELETED)
    response = authed_client.put('/messages/conversations/1',
                                 data=json.dumps({'deleted': True
                                                  })).get_json()['response']
    assert response == 'Successfully modified conversation 1.'

    convs = PrivateConversation.from_user(1, filter='deleted')
    assert len(convs) == 1
    assert convs[0].id == 1
    convs = PrivateConversation.from_user(1, filter='inbox')
    assert len(convs) == 1
예제 #2
0
def view_conversations(user: User,
                       page: int = 1,
                       limit: int = 50,
                       filter: str = 'inbox'):
    return flask.jsonify({
        'conversations_count':
        PrivateConversation.count_from_user(user.id, filter=filter),
        'conversations':
        PrivateConversation.from_user(user_id=user.id,
                                      page=page,
                                      limit=limit,
                                      filter=filter),
    })
예제 #3
0
def test_delete_conversation_in_bulk(app, authed_client):
    response = authed_client.put(
        '/messages/conversations',
        data=json.dumps({
            'conversation_ids': [1, 2],
            'deleted': True
        }),
    ).get_json()['response']
    assert response == 'Successfully modified conversations 1, 2.'
    assert (PrivateConversationState.from_attrs(conv_id=1, user_id=1).deleted
            is True)
    assert (PrivateConversationState.from_attrs(conv_id=2, user_id=1).deleted
            is True)
    assert len(PrivateConversation.from_user(1)) == 0
예제 #4
0
def test_conversation_from_user_deletebox_no_perm(authed_client):
    with pytest.raises(_403Exception):
        PrivateConversation.from_user(1, filter='deleted')
예제 #5
0
def test_conversation_from_user_deletebox_empty(app, authed_client):
    add_permissions(app, MessagePermissions.VIEW_DELETED)
    convs = PrivateConversation.from_user(1, filter='deleted')
    assert len(convs) == 0
예제 #6
0
def test_conversation_from_user_sentbox(client):
    convs = PrivateConversation.from_user(1, filter='sentbox')
    assert len(convs) == 3
    assert all(c.id in {1, 2, 3} for c in convs)
예제 #7
0
def test_conversation_from_user_inbox(client):
    convs = PrivateConversation.from_user(1)
    assert len(convs) == 2
    assert all(c.id in {1, 2} for c in convs)