Fix Client.mark_as_(un)read, and add tests
This commit is contained in:
@@ -558,7 +558,7 @@ class Client:
|
|||||||
"shouldSendReadReceipt": "true",
|
"shouldSendReadReceipt": "true",
|
||||||
}
|
}
|
||||||
|
|
||||||
for threads in threads:
|
for thread in threads:
|
||||||
data["ids[{}]".format(thread.id)] = "true" if read else "false"
|
data["ids[{}]".format(thread.id)] = "true" if read else "false"
|
||||||
|
|
||||||
j = self.session._payload_post("/ajax/mercury/change_read_status.php", data)
|
j = self.session._payload_post("/ajax/mercury/change_read_status.php", data)
|
||||||
|
@@ -17,12 +17,33 @@ def session(pytestconfig):
|
|||||||
|
|
||||||
pytestconfig.cache.set("session_cookies", session.get_cookies())
|
pytestconfig.cache.set("session_cookies", session.get_cookies())
|
||||||
|
|
||||||
|
# TODO: Allow the main session object to be closed - and perhaps used in `with`?
|
||||||
|
session._session.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def client(session):
|
def client(session):
|
||||||
return fbchat.Client(session=session)
|
return fbchat.Client(session=session)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def user(pytestconfig, session):
|
||||||
|
user_id = pytestconfig.cache.get("user_id", None)
|
||||||
|
if not user_id:
|
||||||
|
user_id = input("A user you're chatting with's id: ")
|
||||||
|
pytestconfig.cache.set("user_id", user_id)
|
||||||
|
return fbchat.User(session=session, id=user_id)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def group(pytestconfig, session):
|
||||||
|
group_id = pytestconfig.cache.get("group_id", None)
|
||||||
|
if not group_id:
|
||||||
|
group_id = input("A group you're chatting with's id: ")
|
||||||
|
pytestconfig.cache.set("group_id", group_id)
|
||||||
|
return fbchat.Group(session=session, id=group_id)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def listener(session):
|
def listener(session):
|
||||||
return fbchat.Listener(session=session, chat_on=False, foreground=False)
|
return fbchat.Listener(session=session, chat_on=False, foreground=False)
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import fbchat
|
import fbchat
|
||||||
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
pytestmark = pytest.mark.online
|
pytestmark = pytest.mark.online
|
||||||
@@ -93,5 +94,9 @@ def test_upload_many(client, open_resource):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# def test_mark_as_read(client):
|
def test_mark_as_read(client, user, group):
|
||||||
# client.mark_as_read([thread1, thread2])
|
client.mark_as_read([user, group], datetime.datetime.now())
|
||||||
|
|
||||||
|
|
||||||
|
def test_mark_as_unread(client, user, group):
|
||||||
|
client.mark_as_unread([user, group], datetime.datetime.now())
|
||||||
|
Reference in New Issue
Block a user