Mastodonplus.py/tests/test_polls.py

31 líneas
980 B
Python
Original Vista normal Històric

2019-04-29 17:36:07 +02:00
import pytest
@pytest.mark.vcr()
def test_polls(api, api2):
poll_params = api2.make_poll(["four twenty", "sixty-nine"], 300, multiple=True)
status_poll = api2.status_post("nice", poll=poll_params)
poll = status_poll.poll
assert poll.votes_count == 0
2019-10-12 19:57:14 +02:00
assert poll.own_votes == []
2019-04-29 17:36:07 +02:00
api.poll_vote(status_poll.poll, [1])
poll2 = api.poll(poll)
assert poll2.votes_count == 1
2019-10-12 19:56:48 +02:00
assert poll2.own_votes == [1]
2019-04-29 17:36:07 +02:00
api.poll_vote(status_poll.poll, [0])
poll3 = api.poll(poll)
assert poll3.votes_count == 2
2019-10-12 19:56:48 +02:00
assert poll3.own_votes == [1, 0]
2019-04-29 17:36:07 +02:00
api2.status_delete(status_poll)
@pytest.mark.vcr()
@pytest.mark.xfail(strict=True)
def test_poll_illegal_vote(api, api2):
poll_params = api2.make_poll(["four twenty", "sixty-nine"], 300, multiple=False)
status_poll = api2.status_post("nice", poll=poll_params)
poll = status_poll.poll
api.poll_vote(status_poll.poll, [1])
api.poll_vote(status_poll.poll, [0])