Fix Client.mark_as_(un)read, and add tests
This commit is contained in:
@@ -17,12 +17,33 @@ def session(pytestconfig):
|
||||
|
||||
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
|
||||
def client(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
|
||||
def listener(session):
|
||||
return fbchat.Listener(session=session, chat_on=False, foreground=False)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
import fbchat
|
||||
import datetime
|
||||
import os
|
||||
|
||||
pytestmark = pytest.mark.online
|
||||
@@ -93,5 +94,9 @@ def test_upload_many(client, open_resource):
|
||||
)
|
||||
|
||||
|
||||
# def test_mark_as_read(client):
|
||||
# client.mark_as_read([thread1, thread2])
|
||||
def test_mark_as_read(client, user, group):
|
||||
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