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:
Mads Marquart
2019-09-08 19:53:55 +02:00
parent 8d8ef6bbc9
commit 614e5ad4bb
24 changed files with 453 additions and 449 deletions

View File

@@ -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()