Пример #1
0
def test_on_plan_ended(client, thread, catch_event, compare):
    with catch_event("onPlanEnded") as x:
        client.createPlan(Plan(int(time()) + 120, "Wait for ending"))
        x.wait(180)
    assert subset(
        x.res,
        thread_id=client.uid if thread["type"] == ThreadType.USER else thread["id"],
        thread_type=thread["type"],
    )
Пример #2
0
def test_edit_plan(client, thread, catch_event, compare, plan_data):
    event, plan = plan_data
    new_plan = Plan(plan.time + 100, random_hex())
    with catch_event("on_plan_edited") as x:
        client.edit_plan(plan, new_plan)
    assert compare(x)
    assert subset(
        vars(x.res["plan"]),
        time=new_plan.time,
        title=new_plan.title,
        author_id=client.uid,
    )
Пример #3
0
import pytest

from fbchat import Plan, FBchatFacebookError, ThreadType
from utils import random_hex, subset
from time import time

pytestmark = pytest.mark.online


@pytest.fixture(
    scope="module",
    params=[
        Plan(int(time()) + 100, random_hex()),
        pytest.param(
            Plan(int(time()), random_hex()),
            marks=[pytest.mark.xfail(raises=FBchatFacebookError)],
        ),
        pytest.param(Plan(0, None), marks=[pytest.mark.xfail()]),
    ],
)
def plan_data(request, client, user, thread, catch_event, compare):
    with catch_event("on_plan_created") as x:
        client.create_plan(request.param, thread["id"])
    assert compare(x)
    assert subset(
        vars(x.res["plan"]),
        time=request.param.time,
        title=request.param.title,
        author_id=client.uid,
        going=[client.uid],
        declined=[],
Пример #4
0
import pytest

from fbchat import Plan, FBchatFacebookError, ThreadType
from utils import random_hex, subset
from time import time

pytestmark = pytest.mark.online


@pytest.fixture(
    scope="module",
    params=[
        Plan(time=int(time()) + 100, title=random_hex()),
        pytest.param(
            Plan(time=int(time()), title=random_hex()),
            marks=[pytest.mark.xfail(raises=FBchatFacebookError)],
        ),
        pytest.param(Plan(time=0, title=None), marks=[pytest.mark.xfail()]),
    ],
)
def plan_data(request, client, user, thread, catch_event, compare):
    with catch_event("on_plan_created") as x:
        client.create_plan(request.param, thread["id"])
    assert compare(x)
    assert subset(
        vars(x.res["plan"]),
        time=request.param.time,
        title=request.param.title,
        author_id=client.uid,
        going=[client.uid],
        declined=[],