Add send online tests
This commit is contained in:
@@ -44,6 +44,24 @@ def group(pytestconfig, session):
|
||||
return fbchat.Group(session=session, id=group_id)
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
scope="session",
|
||||
params=[
|
||||
"user",
|
||||
"group",
|
||||
"self",
|
||||
pytest.param("invalid", marks=[pytest.mark.xfail()]),
|
||||
],
|
||||
)
|
||||
def any_thread(request, session, user, group):
|
||||
return {
|
||||
"user": user,
|
||||
"group": group,
|
||||
"self": session.user,
|
||||
"invalid": fbchat.Thread(session=session, id="0"),
|
||||
}[request.param]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def listener(session):
|
||||
return fbchat.Listener(session=session, chat_on=False, foreground=False)
|
||||
|
42
tests/online/test_send.py
Normal file
42
tests/online/test_send.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import pytest
|
||||
import fbchat
|
||||
|
||||
pytestmark = pytest.mark.online
|
||||
|
||||
|
||||
# TODO: Verify return values
|
||||
|
||||
|
||||
def test_wave(any_thread):
|
||||
assert any_thread.wave(True)
|
||||
assert any_thread.wave(False)
|
||||
|
||||
|
||||
def test_send_text(any_thread):
|
||||
assert any_thread.send_text("Test")
|
||||
|
||||
|
||||
def test_send_text_with_mention(any_thread):
|
||||
mention = fbchat.Mention(thread_id=any_thread.id, offset=5, length=8)
|
||||
assert any_thread.send_text("Test @mention", mentions=[mention])
|
||||
|
||||
|
||||
def test_send_emoji(any_thread):
|
||||
assert any_thread.send_emoji("😀", size=fbchat.EmojiSize.LARGE)
|
||||
|
||||
|
||||
def test_send_sticker(any_thread):
|
||||
assert any_thread.send_sticker("1889713947839631")
|
||||
|
||||
|
||||
def test_send_location(any_thread):
|
||||
any_thread.send_location(51.5287718, -0.2416815)
|
||||
|
||||
|
||||
def test_send_pinned_location(any_thread):
|
||||
any_thread.send_pinned_location(39.9390731, 116.117273)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="need a way to use the uploaded files from test_client.py")
|
||||
def test_send_files(any_thread):
|
||||
pass
|
Reference in New Issue
Block a user