Re-add a few online tests, to easily check when Facebook breaks stuff

This commit is contained in:
Mads Marquart
2020-05-06 13:08:57 +02:00
parent 5d763dfbce
commit 2545a01450
3 changed files with 129 additions and 0 deletions

28
tests/online/conftest.py Normal file
View File

@@ -0,0 +1,28 @@
import fbchat
import pytest
import logging
import getpass
@pytest.fixture(scope="session")
def session(pytestconfig):
session_cookies = pytestconfig.cache.get("session_cookies", None)
try:
session = fbchat.Session.from_cookies(session_cookies)
except fbchat.FacebookError:
logging.exception("Error while logging in with cookies!")
session = fbchat.Session.login(input("Email: "), getpass.getpass("Password: "))
yield session
pytestconfig.cache.set("session_cookies", session.get_cookies())
@pytest.fixture
def client(session):
return fbchat.Client(session=session)
@pytest.fixture
def listener(session):
return fbchat.Listener(session=session, chat_on=False, foreground=False)