Use snake_case method names
Renamed: - Message.formatMentions - _util.digitToChar - _util.generateMessageID - _util.getSignatureID - _util.generateOfflineThreadingID - Client._markAlive Renamed following Client methods: - isLoggedIn - getSession - setSession - _forcedFetch - fetchThreads - fetchAllUsersFromThreads - fetchAllUsers - searchForUsers - searchForPages - searchForGroups - searchForThreads - searchForMessageIDs - searchForMessages - _fetchInfo - fetchUserInfo - fetchPageInfo - fetchGroupInfo - fetchThreadInfo - fetchThreadMessages - fetchThreadList - fetchUnread - fetchUnseen - fetchImageUrl - fetchMessageInfo - fetchPollOptions - fetchPlanInfo - _getPrivateData - getPhoneNumbers - getEmails - getUserActiveStatus - fetchThreadImages - _oldMessage - _doSendRequest - quickReply - _sendLocation - sendLocation - sendPinnedLocation - _sendFiles - sendRemoteFiles - sendLocalFiles - sendRemoteVoiceClips - sendLocalVoiceClips - forwardAttachment - createGroup - addUsersToGroup - removeUserFromGroup - _adminStatus - addGroupAdmins - removeGroupAdmins - changeGroupApprovalMode - _usersApproval - acceptUsersToGroup - denyUsersFromGroup - _changeGroupImage - changeGroupImageRemote - changeGroupImageLocal - changeThreadTitle - changeNickname - changeThreadColor - changeThreadEmoji - reactToMessage - createPlan - editPlan - deletePlan - changePlanParticipation - createPoll - updatePollVote - setTypingStatus - markAsDelivered - _readStatus - markAsRead - markAsUnread - markAsSeen - friendConnect - removeFriend - blockUser - unblockUser - moveThreads - deleteThreads - markAsSpam - deleteMessages - muteThread - unmuteThread - muteThreadReactions - unmuteThreadReactions - muteThreadMentions - unmuteThreadMentions - _pullMessage - _parseMessage - _doOneListen - setActiveStatus - onLoggingIn - on2FACode - onLoggedIn - onListening - onListenError - onMessage - onColorChange - onEmojiChange - onTitleChange - onImageChange - onNicknameChange - onAdminAdded - onAdminRemoved - onApprovalModeChange - onMessageSeen - onMessageDelivered - onMarkedSeen - onMessageUnsent - onPeopleAdded - onPersonRemoved - onFriendRequest - onInbox - onTyping - onGamePlayed - onReactionAdded - onReactionRemoved - onBlock - onUnblock - onLiveLocation - onCallStarted - onCallEnded - onUserJoinedCall - onPollCreated - onPollVoted - onPlanCreated - onPlanEnded - onPlanEdited - onPlanDeleted - onPlanParticipation - onQprimer - onChatTimestamp - onBuddylistOverlay - onUnknownMesssageType - onMessageError
This commit is contained in:
@@ -88,7 +88,7 @@ def catch_event(client2):
|
||||
try:
|
||||
# Make the client send a messages to itself, so the blocking pull request will return
|
||||
# This is probably not safe, since the client is making two requests simultaneously
|
||||
client2.sendMessage(random_hex(), client2.uid)
|
||||
client2.send(Message(text=random_hex()), client2.uid)
|
||||
finally:
|
||||
t.join()
|
||||
|
||||
|
@@ -16,25 +16,25 @@ def test_examples():
|
||||
@pytest.mark.trylast
|
||||
@pytest.mark.expensive
|
||||
def test_login(client1):
|
||||
assert client1.isLoggedIn()
|
||||
assert client1.is_logged_in()
|
||||
email = client1.email
|
||||
password = client1.password
|
||||
|
||||
client1.logout()
|
||||
|
||||
assert not client1.isLoggedIn()
|
||||
assert not client1.is_logged_in()
|
||||
|
||||
with pytest.raises(FBchatException):
|
||||
client1.login("<invalid email>", "<invalid password>", max_tries=1)
|
||||
|
||||
client1.login(email, password)
|
||||
|
||||
assert client1.isLoggedIn()
|
||||
assert client1.is_logged_in()
|
||||
|
||||
|
||||
@pytest.mark.trylast
|
||||
def test_sessions(client1):
|
||||
session = client1.getSession()
|
||||
session = client1.get_session()
|
||||
Client("no email needed", "no password needed", session_cookies=session)
|
||||
client1.setSession(session)
|
||||
assert client1.isLoggedIn()
|
||||
client1.set_session(session)
|
||||
assert client1.is_logged_in()
|
||||
|
@@ -6,24 +6,24 @@ from utils import subset, STICKER_LIST, EMOJI_LIST
|
||||
|
||||
|
||||
def test_fetch_all_users(client1):
|
||||
users = client1.fetchAllUsers()
|
||||
users = client1.fetch_all_users()
|
||||
assert len(users) > 0
|
||||
|
||||
|
||||
def test_fetch_thread_list(client1):
|
||||
threads = client1.fetchThreadList(limit=2)
|
||||
threads = client1.fetch_thread_list(limit=2)
|
||||
assert len(threads) == 2
|
||||
|
||||
|
||||
def test_fetch_threads(client1):
|
||||
threads = client1.fetchThreads(limit=2)
|
||||
threads = client1.fetch_threads(limit=2)
|
||||
assert len(threads) == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("emoji, emoji_size", EMOJI_LIST)
|
||||
def test_fetch_message_emoji(client, emoji, emoji_size):
|
||||
mid = client.sendEmoji(emoji, emoji_size)
|
||||
message, = client.fetchThreadMessages(limit=1)
|
||||
mid = client.send_emoji(emoji, emoji_size)
|
||||
message, = client.fetch_thread_messages(limit=1)
|
||||
|
||||
assert subset(
|
||||
vars(message), uid=mid, author=client.uid, text=emoji, emoji_size=emoji_size
|
||||
@@ -32,8 +32,8 @@ def test_fetch_message_emoji(client, emoji, emoji_size):
|
||||
|
||||
@pytest.mark.parametrize("emoji, emoji_size", EMOJI_LIST)
|
||||
def test_fetch_message_info_emoji(client, thread, emoji, emoji_size):
|
||||
mid = client.sendEmoji(emoji, emoji_size)
|
||||
message = client.fetchMessageInfo(mid, thread_id=thread["id"])
|
||||
mid = client.send_emoji(emoji, emoji_size)
|
||||
message = client.fetch_message_info(mid, thread_id=thread["id"])
|
||||
|
||||
assert subset(
|
||||
vars(message), uid=mid, author=client.uid, text=emoji, emoji_size=emoji_size
|
||||
@@ -42,7 +42,7 @@ def test_fetch_message_info_emoji(client, thread, emoji, emoji_size):
|
||||
|
||||
def test_fetch_message_mentions(client, thread, message_with_mentions):
|
||||
mid = client.send(message_with_mentions)
|
||||
message, = client.fetchThreadMessages(limit=1)
|
||||
message, = client.fetch_thread_messages(limit=1)
|
||||
|
||||
assert subset(
|
||||
vars(message), uid=mid, author=client.uid, text=message_with_mentions.text
|
||||
@@ -54,7 +54,7 @@ def test_fetch_message_mentions(client, thread, message_with_mentions):
|
||||
|
||||
def test_fetch_message_info_mentions(client, thread, message_with_mentions):
|
||||
mid = client.send(message_with_mentions)
|
||||
message = client.fetchMessageInfo(mid, thread_id=thread["id"])
|
||||
message = client.fetch_message_info(mid, thread_id=thread["id"])
|
||||
|
||||
assert subset(
|
||||
vars(message), uid=mid, author=client.uid, text=message_with_mentions.text
|
||||
@@ -67,7 +67,7 @@ def test_fetch_message_info_mentions(client, thread, message_with_mentions):
|
||||
@pytest.mark.parametrize("sticker", STICKER_LIST)
|
||||
def test_fetch_message_sticker(client, sticker):
|
||||
mid = client.send(Message(sticker=sticker))
|
||||
message, = client.fetchThreadMessages(limit=1)
|
||||
message, = client.fetch_thread_messages(limit=1)
|
||||
|
||||
assert subset(vars(message), uid=mid, author=client.uid)
|
||||
assert subset(vars(message.sticker), uid=sticker.uid)
|
||||
@@ -76,22 +76,24 @@ def test_fetch_message_sticker(client, sticker):
|
||||
@pytest.mark.parametrize("sticker", STICKER_LIST)
|
||||
def test_fetch_message_info_sticker(client, thread, sticker):
|
||||
mid = client.send(Message(sticker=sticker))
|
||||
message = client.fetchMessageInfo(mid, thread_id=thread["id"])
|
||||
message = client.fetch_message_info(mid, thread_id=thread["id"])
|
||||
|
||||
assert subset(vars(message), uid=mid, author=client.uid)
|
||||
assert subset(vars(message.sticker), uid=sticker.uid)
|
||||
|
||||
|
||||
def test_fetch_info(client1, group):
|
||||
info = client1.fetchUserInfo("4")["4"]
|
||||
info = client1.fetch_user_info("4")["4"]
|
||||
assert info.name == "Mark Zuckerberg"
|
||||
|
||||
info = client1.fetchGroupInfo(group["id"])[group["id"]]
|
||||
info = client1.fetch_group_info(group["id"])[group["id"]]
|
||||
assert info.type == ThreadType.GROUP
|
||||
|
||||
|
||||
def test_fetch_image_url(client):
|
||||
client.sendLocalFiles([path.join(path.dirname(__file__), "resources", "image.png")])
|
||||
message, = client.fetchThreadMessages(limit=1)
|
||||
client.send_local_files(
|
||||
[path.join(path.dirname(__file__), "resources", "image.png")]
|
||||
)
|
||||
message, = client.fetch_thread_messages(limit=1)
|
||||
|
||||
assert client.fetchImageUrl(message.attachments[0].uid)
|
||||
assert client.fetch_image_url(message.attachments[0].uid)
|
||||
|
@@ -6,14 +6,14 @@ 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)
|
||||
client.react_to_message(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)
|
||||
mid1 = client.send(Message(text=text1))
|
||||
mid2 = client.send(Message(text=text2))
|
||||
client.delete_messages(mid2)
|
||||
message, = client.fetch_thread_messages(limit=1)
|
||||
assert subset(vars(message), uid=mid1, author=client.uid, text=text1)
|
||||
|
@@ -17,8 +17,8 @@ from time import time
|
||||
],
|
||||
)
|
||||
def plan_data(request, client, user, thread, catch_event, compare):
|
||||
with catch_event("onPlanCreated") as x:
|
||||
client.createPlan(request.param, thread["id"])
|
||||
with catch_event("on_plan_created") as x:
|
||||
client.create_plan(request.param, thread["id"])
|
||||
assert compare(x)
|
||||
assert subset(
|
||||
vars(x.res["plan"]),
|
||||
@@ -32,8 +32,8 @@ def plan_data(request, client, user, thread, catch_event, compare):
|
||||
assert user["id"] in x.res["plan"].invited
|
||||
request.param.uid = x.res["plan"].uid
|
||||
yield x.res, request.param
|
||||
with catch_event("onPlanDeleted") as x:
|
||||
client.deletePlan(plan_id)
|
||||
with catch_event("on_plan_deleted") as x:
|
||||
client.delete_plan(plan_id)
|
||||
assert compare(x)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ def test_create_delete_plan(plan_data):
|
||||
|
||||
def test_fetch_plan_info(client, catch_event, plan_data):
|
||||
event, plan = plan_data
|
||||
fetched_plan = client.fetchPlanInfo(plan.uid)
|
||||
fetched_plan = client.fetch_plan_info(plan.uid)
|
||||
assert subset(
|
||||
vars(fetched_plan), time=plan.time, title=plan.title, author_id=int(client.uid)
|
||||
)
|
||||
@@ -55,8 +55,8 @@ def test_change_plan_participation(
|
||||
client, thread, catch_event, compare, plan_data, take_part
|
||||
):
|
||||
event, plan = plan_data
|
||||
with catch_event("onPlanParticipation") as x:
|
||||
client.changePlanParticipation(plan, take_part=take_part)
|
||||
with catch_event("on_plan_participation") as x:
|
||||
client.change_plan_participation(plan, take_part=take_part)
|
||||
assert compare(x, take_part=take_part)
|
||||
assert subset(
|
||||
vars(x.res["plan"]),
|
||||
@@ -72,8 +72,8 @@ def test_change_plan_participation(
|
||||
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("onPlanEdited") as x:
|
||||
client.editPlan(plan, new_plan)
|
||||
with catch_event("on_plan_edited") as x:
|
||||
client.edit_plan(plan, new_plan)
|
||||
assert compare(x)
|
||||
assert subset(
|
||||
vars(x.res["plan"]),
|
||||
@@ -86,8 +86,8 @@ def test_edit_plan(client, thread, catch_event, compare, plan_data):
|
||||
@pytest.mark.trylast
|
||||
@pytest.mark.expensive
|
||||
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"))
|
||||
with catch_event("on_plan_ended") as x:
|
||||
client.create_plan(Plan(int(time()) + 120, "Wait for ending"))
|
||||
x.wait(180)
|
||||
assert subset(
|
||||
x.res,
|
||||
@@ -96,15 +96,15 @@ def test_on_plan_ended(client, thread, catch_event, compare):
|
||||
)
|
||||
|
||||
|
||||
# createPlan(self, plan, thread_id=None)
|
||||
# editPlan(self, plan, new_plan)
|
||||
# deletePlan(self, plan)
|
||||
# changePlanParticipation(self, plan, take_part=True)
|
||||
# create_plan(self, plan, thread_id=None)
|
||||
# edit_plan(self, plan, new_plan)
|
||||
# delete_plan(self, plan)
|
||||
# change_plan_participation(self, plan, take_part=True)
|
||||
|
||||
# onPlanCreated(self, mid=None, plan=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# onPlanEnded(self, mid=None, plan=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# onPlanEdited(self, mid=None, plan=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# onPlanDeleted(self, mid=None, plan=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# onPlanParticipation(self, mid=None, plan=None, take_part=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# on_plan_created(self, mid=None, plan=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# on_plan_ended(self, mid=None, plan=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# on_plan_edited(self, mid=None, plan=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# on_plan_deleted(self, mid=None, plan=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
# on_plan_participation(self, mid=None, plan=None, take_part=None, author_id=None, thread_id=None, thread_type=None, ts=None, metadata=None, msg=None)
|
||||
|
||||
# fetchPlanInfo(self, plan_id)
|
||||
# fetch_plan_info(self, plan_id)
|
||||
|
@@ -39,9 +39,9 @@ from utils import random_hex, subset
|
||||
],
|
||||
)
|
||||
def poll_data(request, client1, group, catch_event):
|
||||
with catch_event("onPollCreated") as x:
|
||||
client1.createPoll(request.param, thread_id=group["id"])
|
||||
options = client1.fetchPollOptions(x.res["poll"].uid)
|
||||
with catch_event("on_poll_created") as x:
|
||||
client1.create_poll(request.param, thread_id=group["id"])
|
||||
options = client1.fetch_poll_options(x.res["poll"].uid)
|
||||
return x.res, request.param, options
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ def test_update_poll_vote(client1, group, catch_event, poll_data):
|
||||
new_vote_ids = [o.uid for o in options[0 : len(options) : 2] if not o.vote]
|
||||
re_vote_ids = [o.uid for o in options[0 : len(options) : 2] if o.vote]
|
||||
new_options = [random_hex(), random_hex()]
|
||||
with catch_event("onPollVoted") as x:
|
||||
client1.updatePollVote(
|
||||
with catch_event("on_poll_voted") as x:
|
||||
client1.update_poll_vote(
|
||||
event["poll"].uid,
|
||||
option_ids=new_vote_ids + re_vote_ids,
|
||||
new_options=new_options,
|
||||
|
@@ -2,7 +2,7 @@ from fbchat import ThreadType
|
||||
|
||||
|
||||
def test_search_for(client1):
|
||||
users = client1.searchForUsers("Mark Zuckerberg")
|
||||
users = client1.search_for_users("Mark Zuckerberg")
|
||||
assert len(users) > 0
|
||||
|
||||
u = users[0]
|
||||
|
@@ -7,8 +7,8 @@ from utils import subset, STICKER_LIST, EMOJI_LIST, TEXT_LIST
|
||||
|
||||
@pytest.mark.parametrize("text", TEXT_LIST)
|
||||
def test_send_text(client, catch_event, compare, text):
|
||||
with catch_event("onMessage") as x:
|
||||
mid = client.sendMessage(text)
|
||||
with catch_event("on_message") as x:
|
||||
mid = client.send(Message(text=text))
|
||||
|
||||
assert compare(x, mid=mid, message=text)
|
||||
assert subset(vars(x.res["message_object"]), uid=mid, author=client.uid, text=text)
|
||||
@@ -16,8 +16,8 @@ def test_send_text(client, catch_event, compare, text):
|
||||
|
||||
@pytest.mark.parametrize("emoji, emoji_size", EMOJI_LIST)
|
||||
def test_send_emoji(client, catch_event, compare, emoji, emoji_size):
|
||||
with catch_event("onMessage") as x:
|
||||
mid = client.sendEmoji(emoji, emoji_size)
|
||||
with catch_event("on_message") as x:
|
||||
mid = client.send_emoji(emoji, emoji_size)
|
||||
|
||||
assert compare(x, mid=mid, message=emoji)
|
||||
assert subset(
|
||||
@@ -30,7 +30,7 @@ def test_send_emoji(client, catch_event, compare, emoji, emoji_size):
|
||||
|
||||
|
||||
def test_send_mentions(client, catch_event, compare, message_with_mentions):
|
||||
with catch_event("onMessage") as x:
|
||||
with catch_event("on_message") as x:
|
||||
mid = client.send(message_with_mentions)
|
||||
|
||||
assert compare(x, mid=mid, message=message_with_mentions.text)
|
||||
@@ -47,7 +47,7 @@ def test_send_mentions(client, catch_event, compare, message_with_mentions):
|
||||
|
||||
@pytest.mark.parametrize("sticker", STICKER_LIST)
|
||||
def test_send_sticker(client, catch_event, compare, sticker):
|
||||
with catch_event("onMessage") as x:
|
||||
with catch_event("on_message") as x:
|
||||
mid = client.send(Message(sticker=sticker))
|
||||
|
||||
assert compare(x, mid=mid)
|
||||
@@ -68,7 +68,7 @@ def test_send_sticker(client, catch_event, compare, sticker):
|
||||
)
|
||||
def test_send_images(client, catch_event, compare, method_name, url):
|
||||
text = "An image sent with {}".format(method_name)
|
||||
with catch_event("onMessage") as x:
|
||||
with catch_event("on_message") as x:
|
||||
mid = getattr(client, method_name)(url, Message(text))
|
||||
|
||||
assert compare(x, mid=mid, message=text)
|
||||
@@ -87,8 +87,8 @@ def test_send_local_files(client, catch_event, compare):
|
||||
"video.mp4",
|
||||
]
|
||||
text = "Files sent locally"
|
||||
with catch_event("onMessage") as x:
|
||||
mid = client.sendLocalFiles(
|
||||
with catch_event("on_message") as x:
|
||||
mid = client.send_local_files(
|
||||
[path.join(path.dirname(__file__), "resources", f) for f in files],
|
||||
message=Message(text),
|
||||
)
|
||||
@@ -102,8 +102,8 @@ def test_send_local_files(client, catch_event, compare):
|
||||
def test_send_remote_files(client, catch_event, compare):
|
||||
files = ["image.png", "data.json"]
|
||||
text = "Files sent from remote"
|
||||
with catch_event("onMessage") as x:
|
||||
mid = client.sendRemoteFiles(
|
||||
with catch_event("on_message") as x:
|
||||
mid = client.send_remote_files(
|
||||
[
|
||||
"https://github.com/carpedm20/fbchat/raw/master/tests/{}".format(f)
|
||||
for f in files
|
||||
|
@@ -3,6 +3,6 @@ import pytest
|
||||
|
||||
def test_catch_event(client2, catch_event):
|
||||
mid = "test"
|
||||
with catch_event("onMessage") as x:
|
||||
client2.onMessage(mid=mid)
|
||||
with catch_event("on_message") as x:
|
||||
client2.on_message(mid=mid)
|
||||
assert x.res["mid"] == mid
|
||||
|
@@ -8,14 +8,14 @@ from os import path
|
||||
def test_remove_from_and_add_to_group(client1, client2, group, catch_event):
|
||||
# Test both methods, while ensuring that the user gets added to the group
|
||||
try:
|
||||
with catch_event("onPersonRemoved") as x:
|
||||
client1.removeUserFromGroup(client2.uid, group["id"])
|
||||
with catch_event("on_person_removed") as x:
|
||||
client1.remove_user_from_group(client2.uid, group["id"])
|
||||
assert subset(
|
||||
x.res, removed_id=client2.uid, author_id=client1.uid, thread_id=group["id"]
|
||||
)
|
||||
finally:
|
||||
with catch_event("onPeopleAdded") as x:
|
||||
client1.addUsersToGroup(client2.uid, group["id"])
|
||||
with catch_event("on_people_added") as x:
|
||||
client1.add_users_to_group(client2.uid, group["id"])
|
||||
assert subset(
|
||||
x.res, added_ids=[client2.uid], author_id=client1.uid, thread_id=group["id"]
|
||||
)
|
||||
@@ -24,14 +24,14 @@ def test_remove_from_and_add_to_group(client1, client2, group, catch_event):
|
||||
def test_remove_from_and_add_admins_to_group(client1, client2, group, catch_event):
|
||||
# Test both methods, while ensuring that the user gets added as group admin
|
||||
try:
|
||||
with catch_event("onAdminRemoved") as x:
|
||||
client1.removeGroupAdmins(client2.uid, group["id"])
|
||||
with catch_event("on_admin_removed") as x:
|
||||
client1.remove_group_admins(client2.uid, group["id"])
|
||||
assert subset(
|
||||
x.res, removed_id=client2.uid, author_id=client1.uid, thread_id=group["id"]
|
||||
)
|
||||
finally:
|
||||
with catch_event("onAdminAdded") as x:
|
||||
client1.addGroupAdmins(client2.uid, group["id"])
|
||||
with catch_event("on_admin_added") as x:
|
||||
client1.add_group_admins(client2.uid, group["id"])
|
||||
assert subset(
|
||||
x.res, added_id=client2.uid, author_id=client1.uid, thread_id=group["id"]
|
||||
)
|
||||
@@ -39,8 +39,8 @@ 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:
|
||||
client1.changeThreadTitle(title, group["id"], thread_type=ThreadType.GROUP)
|
||||
with catch_event("on_title_change") as x:
|
||||
client1.change_thread_title(title, group["id"], thread_type=ThreadType.GROUP)
|
||||
assert subset(
|
||||
x.res,
|
||||
author_id=client1.uid,
|
||||
@@ -52,8 +52,8 @@ def test_change_title(client1, group, catch_event):
|
||||
|
||||
def test_change_nickname(client, client_all, catch_event, compare):
|
||||
nickname = random_hex()
|
||||
with catch_event("onNicknameChange") as x:
|
||||
client.changeNickname(nickname, client_all.uid)
|
||||
with catch_event("on_nickname_change") as x:
|
||||
client.change_nickname(nickname, client_all.uid)
|
||||
assert compare(x, changed_for=client_all.uid, new_nickname=nickname)
|
||||
|
||||
|
||||
@@ -71,15 +71,15 @@ def test_change_nickname(client, client_all, catch_event, compare):
|
||||
],
|
||||
)
|
||||
def test_change_emoji(client, catch_event, compare, emoji):
|
||||
with catch_event("onEmojiChange") as x:
|
||||
client.changeThreadEmoji(emoji)
|
||||
with catch_event("on_emoji_change") as x:
|
||||
client.change_thread_emoji(emoji)
|
||||
assert compare(x, new_emoji=emoji)
|
||||
|
||||
|
||||
def test_change_image_local(client1, group, catch_event):
|
||||
url = path.join(path.dirname(__file__), "resources", "image.png")
|
||||
with catch_event("onImageChange") as x:
|
||||
image_id = client1.changeGroupImageLocal(url, group["id"])
|
||||
with catch_event("on_image_change") as x:
|
||||
image_id = client1.change_group_image_local(url, group["id"])
|
||||
assert subset(
|
||||
x.res, new_image=image_id, author_id=client1.uid, thread_id=group["id"]
|
||||
)
|
||||
@@ -88,8 +88,8 @@ def test_change_image_local(client1, group, catch_event):
|
||||
# To be changed when merged into master
|
||||
def test_change_image_remote(client1, group, catch_event):
|
||||
url = "https://github.com/carpedm20/fbchat/raw/master/tests/image.png"
|
||||
with catch_event("onImageChange") as x:
|
||||
image_id = client1.changeGroupImageRemote(url, group["id"])
|
||||
with catch_event("on_image_change") as x:
|
||||
image_id = client1.change_group_image_remote(url, group["id"])
|
||||
assert subset(
|
||||
x.res, new_image=image_id, author_id=client1.uid, thread_id=group["id"]
|
||||
)
|
||||
@@ -105,8 +105,8 @@ def test_change_image_remote(client1, group, catch_event):
|
||||
],
|
||||
)
|
||||
def test_change_color(client, catch_event, compare, color):
|
||||
with catch_event("onColorChange") as x:
|
||||
client.changeThreadColor(color)
|
||||
with catch_event("on_color_change") as x:
|
||||
client.change_thread_color(color)
|
||||
assert compare(x, new_color=color)
|
||||
|
||||
|
||||
@@ -115,20 +115,20 @@ def test_change_color_invalid(client):
|
||||
class InvalidColor:
|
||||
value = "#0077ff"
|
||||
|
||||
client.changeThreadColor(InvalidColor())
|
||||
client.change_thread_color(InvalidColor())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status", TypingStatus)
|
||||
def test_typing_status(client, catch_event, compare, status):
|
||||
with catch_event("onTyping") as x:
|
||||
client.setTypingStatus(status)
|
||||
with catch_event("on_typing") as x:
|
||||
client.set_typing_status(status)
|
||||
assert compare(x, status=status)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("require_admin_approval", [True, False])
|
||||
def test_change_approval_mode(client1, group, catch_event, require_admin_approval):
|
||||
with catch_event("onApprovalModeChange") as x:
|
||||
client1.changeGroupApprovalMode(require_admin_approval, group["id"])
|
||||
with catch_event("on_approval_mode_change") as x:
|
||||
client1.change_group_approval_mode(require_admin_approval, group["id"])
|
||||
|
||||
assert subset(
|
||||
x.res,
|
||||
@@ -140,15 +140,15 @@ def test_change_approval_mode(client1, group, catch_event, require_admin_approva
|
||||
|
||||
@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()
|
||||
assert client.mute_thread(mute_time)
|
||||
assert client.unmute_thread()
|
||||
|
||||
|
||||
def test_mute_thread_reactions(client):
|
||||
assert client.muteThreadReactions()
|
||||
assert client.unmuteThreadReactions()
|
||||
assert client.mute_thread_reactions()
|
||||
assert client.unmute_thread_reactions()
|
||||
|
||||
|
||||
def test_mute_thread_mentions(client):
|
||||
assert client.muteThreadMentions()
|
||||
assert client.unmuteThreadMentions()
|
||||
assert client.mute_thread_mentions()
|
||||
assert client.unmute_thread_mentions()
|
||||
|
@@ -46,11 +46,11 @@ class ClientThread(threading.Thread):
|
||||
super(ClientThread, self).__init__(*args, **kwargs)
|
||||
|
||||
def start(self):
|
||||
self.client._doOneListen() # QPrimer, Facebook now knows we're about to start pulling
|
||||
self.client._do_one_listen() # QPrimer, Facebook now knows we're about to start pulling
|
||||
super(ClientThread, self).start()
|
||||
|
||||
def run(self):
|
||||
while not self.should_stop.is_set() and self.client._doOneListen():
|
||||
while not self.should_stop.is_set() and self.client._do_one_listen():
|
||||
pass
|
||||
|
||||
|
||||
@@ -95,4 +95,4 @@ def load_client(n, cache):
|
||||
max_tries=1,
|
||||
)
|
||||
yield client
|
||||
cache.set("client{}_session".format(n), client.getSession())
|
||||
cache.set("client{}_session".format(n), client.get_session())
|
||||
|
Reference in New Issue
Block a user