def test_modify_poll_choices(app, authed_client):
    add_permissions(app, 'forums_view', 'modify_forum_polls')
    response = authed_client.put(
        '/polls/1',
        data=json.dumps(
            {'choices': {
                'add': ['a', 'b', 'c'],
                'delete': [1, 2]
            }}),
    )
    choices = response.get_json()['response']['choices']
    assert len(choices) == 4
    assert {'Choice C', 'a', 'b',
            'c'} == {choice['choice']
                     for choice in choices}
    choices = ForumPollChoice.from_poll(1)
    assert {'Choice C', 'a', 'b', 'c'} == {choice.choice for choice in choices}
def test_poll_choice_from_poll_nonexistent(app, authed_client):
    choices = ForumPollChoice.from_poll(4)
    assert choices == []