Refactor polls and poll options
This commit is contained in:
@@ -10,7 +10,7 @@ def test_poll_option_from_graphql_unvoted():
|
||||
"voters": [],
|
||||
}
|
||||
assert PollOption(
|
||||
text="abc", vote=False, voters=[], votes_count=0, id=123456789
|
||||
text="abc", vote=False, voters=[], votes_count=0, id="123456789"
|
||||
) == PollOption._from_graphql(data)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_poll_option_from_graphql_voted():
|
||||
"voters": ["1234", "2345"],
|
||||
}
|
||||
assert PollOption(
|
||||
text="abc", vote=True, voters=["1234", "2345"], votes_count=2, id=123456789
|
||||
text="abc", vote=True, voters=["1234", "2345"], votes_count=2, id="123456789"
|
||||
) == PollOption._from_graphql(data)
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ def test_poll_option_from_graphql_alternate_format():
|
||||
},
|
||||
}
|
||||
assert PollOption(
|
||||
text="abc", vote=True, voters=["1234", "2345"], votes_count=2, id=123456789
|
||||
text="abc", vote=True, voters=["1234", "2345"], votes_count=2, id="123456789"
|
||||
) == PollOption._from_graphql(data)
|
||||
|
||||
|
||||
def test_poll_from_graphql():
|
||||
def test_poll_from_graphql(session):
|
||||
data = {
|
||||
"id": "123456789",
|
||||
"text": "Some poll",
|
||||
@@ -74,14 +74,21 @@ def test_poll_from_graphql():
|
||||
],
|
||||
}
|
||||
assert Poll(
|
||||
title="Some poll",
|
||||
session=session,
|
||||
question="Some poll",
|
||||
options=[
|
||||
PollOption(text="Abc", vote=True, voters=["1234"], votes_count=1, id=1111),
|
||||
PollOption(
|
||||
text="Def", vote=False, voters=["2345", "3456"], votes_count=2, id=2222
|
||||
text="Abc", vote=True, voters=["1234"], votes_count=1, id="1111"
|
||||
),
|
||||
PollOption(text="Ghi", vote=False, voters=[], votes_count=0, id=3333),
|
||||
PollOption(
|
||||
text="Def",
|
||||
vote=False,
|
||||
voters=["2345", "3456"],
|
||||
votes_count=2,
|
||||
id="2222",
|
||||
),
|
||||
PollOption(text="Ghi", vote=False, voters=[], votes_count=0, id="3333"),
|
||||
],
|
||||
options_count=5,
|
||||
id=123456789,
|
||||
) == Poll._from_graphql(data)
|
||||
) == Poll._from_graphql(session, data)
|
||||
|
@@ -9,40 +9,26 @@ pytestmark = pytest.mark.online
|
||||
@pytest.fixture(
|
||||
scope="module",
|
||||
params=[
|
||||
Poll(title=random_hex(), options=[]),
|
||||
Poll(
|
||||
title=random_hex(),
|
||||
options=[
|
||||
PollOption(text=random_hex(), vote=True),
|
||||
PollOption(text=random_hex(), vote=True),
|
||||
(random_hex(), []),
|
||||
(random_hex(), [(random_hex(), True), (random_hex(), True),],),
|
||||
(random_hex(), [(random_hex(), False), (random_hex(), False),],),
|
||||
(
|
||||
random_hex(),
|
||||
[
|
||||
(random_hex(), True),
|
||||
(random_hex(), True),
|
||||
(random_hex(), False),
|
||||
(random_hex(), False),
|
||||
(random_hex()),
|
||||
(random_hex()),
|
||||
],
|
||||
),
|
||||
Poll(
|
||||
title=random_hex(),
|
||||
options=[
|
||||
PollOption(text=random_hex(), vote=False),
|
||||
PollOption(text=random_hex(), vote=False),
|
||||
],
|
||||
),
|
||||
Poll(
|
||||
title=random_hex(),
|
||||
options=[
|
||||
PollOption(text=random_hex(), vote=True),
|
||||
PollOption(text=random_hex(), vote=True),
|
||||
PollOption(text=random_hex(), vote=False),
|
||||
PollOption(text=random_hex(), vote=False),
|
||||
PollOption(text=random_hex()),
|
||||
PollOption(text=random_hex()),
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
Poll(title=None, options=[]), marks=[pytest.mark.xfail(raises=ValueError)]
|
||||
),
|
||||
pytest.param((None, []), marks=[pytest.mark.xfail(raises=ValueError)]),
|
||||
],
|
||||
)
|
||||
def poll_data(request, client1, group, catch_event):
|
||||
with catch_event("on_poll_created") as x:
|
||||
client1.create_poll(request.param, thread_id=group["id"])
|
||||
client1.create_poll(request.param[0], request.param[1], thread_id=group["id"])
|
||||
options = client1.fetch_poll_options(x.res["poll"].id)
|
||||
return x.res, request.param, options
|
||||
|
||||
|
Reference in New Issue
Block a user