Skip to content

Commit

Permalink
Add send online tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed May 7, 2020
1 parent d33e368 commit 078bf9f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fbchat/_threads/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def send_pinned_location(self, latitude: float, longitude: float):
Example:
Send a pinned location in Beijing, China.
>>> thread.send_location(39.9390731, 116.117273)
>>> thread.send_pinned_location(39.9390731, 116.117273)
"""
self._send_location(False, latitude=latitude, longitude=longitude)

Expand Down
18 changes: 18 additions & 0 deletions tests/online/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 42 additions & 0 deletions tests/online/test_send.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 078bf9f

Please sign in to comment.