Added more tests

This commit is contained in:
Mads Marquart
2018-08-29 14:07:44 +02:00
parent 0617d7b49f
commit c2225bf2fd
4 changed files with 37 additions and 8 deletions

View File

@@ -20,9 +20,13 @@ def group(pytestconfig):
return {"id": load_variable("group_id", pytestconfig.cache), "type": ThreadType.GROUP}
@pytest.fixture(scope="session", params=["user", "group"])
@pytest.fixture(params=["user", "group", pytest.mark.xfail("none")])
def thread(request, user, group):
return user if request.param == "user" else group
return {
"user": user,
"group": group,
"none": {"id": "0", "type": ThreadType.GROUP}
}[request.param]
@pytest.fixture(scope="session")

View File

@@ -9,13 +9,13 @@ from fbchat.models import ThreadType, Message, Mention, EmojiSize, Sticker
from utils import subset, STICKER_LIST, EMOJI_LIST
def test_fetch_all_users(client):
users = client.fetchAllUsers()
def test_fetch_all_users(client1):
users = client1.fetchAllUsers()
assert len(users) > 0
def test_fetch_thread_list(client):
threads = client.fetchThreadList(limit=2)
def test_fetch_thread_list(client1):
threads = client1.fetchThreadList(limit=2)
assert len(threads) == 2

View File

@@ -5,8 +5,19 @@ from __future__ import unicode_literals
import pytest
from fbchat.models import Message, MessageReaction
from utils import subset
def test_set_reaction(client):
mid = client.send(Message(text="This message will be reacted to"))
client.reactToMessage(mid, MessageReaction.LOVE)
def test_delete_messages(client):
text1 = "This message will stay"
text2 = "This message will be removed"
mid1 = client.sendMessage(text1)
mid2 = client.sendMessage(text2)
client.deleteMessages(mid2)
message, = client.fetchThreadMessages(limit=1)
assert subset(vars(message), uid=mid1, author=client.uid, text=text1)

View File

@@ -50,10 +50,9 @@ def test_remove_from_and_add_admins_to_group(client1, client2, group, catch_even
def test_change_title(client1, group, catch_event):
title = random_hex()
with catch_event("onTitleChange") as x:
mid = client1.changeThreadTitle(title, group["id"])
client1.changeThreadTitle(title, group["id"], thread_type=ThreadType.GROUP)
assert subset(
x.res,
mid=mid,
author_id=client1.uid,
new_title=title,
thread_id=group["id"],
@@ -138,3 +137,18 @@ def test_change_approval_mode(client1, group, catch_event, require_admin_approva
author_id=client1.uid,
thread_id=group["id"],
)
@pytest.mark.parametrize("mute_time", [0, 10, 100, 1000, -1])
def test_mute_thread(client, mute_time):
assert client.muteThread(mute_time)
assert client.unmuteThread()
def test_mute_thread_reactions(client):
assert client.muteThreadReactions()
assert client.unmuteThreadReactions()
def test_mute_thread_mentions(client):
assert client.muteThreadMentions()
assert client.unmuteThreadMentions()