Remove ThreadType completely
This commit is contained in:
@@ -3,7 +3,7 @@ import json
|
||||
|
||||
from utils import *
|
||||
from contextlib import contextmanager
|
||||
from fbchat import ThreadType, Message, Mention
|
||||
from fbchat import Message, Mention
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@@ -13,14 +13,14 @@ def session():
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def user(client2):
|
||||
return {"id": client2.id, "type": ThreadType.USER}
|
||||
return {"id": client2.id, "type": None}
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def group(pytestconfig):
|
||||
return {
|
||||
"id": load_variable("group_id", pytestconfig.cache),
|
||||
"type": ThreadType.GROUP,
|
||||
"type": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,9 @@ def group(pytestconfig):
|
||||
params=["user", "group", pytest.param("none", marks=[pytest.mark.xfail()])],
|
||||
)
|
||||
def thread(request, user, group):
|
||||
return {
|
||||
"user": user,
|
||||
"group": group,
|
||||
"none": {"id": "0", "type": ThreadType.GROUP},
|
||||
}[request.param]
|
||||
return {"user": user, "group": group, "none": {"id": "0", "type": None},}[
|
||||
request.param
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@@ -103,9 +101,7 @@ def compare(client, thread):
|
||||
def inner(caught_event, **kwargs):
|
||||
d = {
|
||||
"author_id": client.id,
|
||||
"thread_id": client.id
|
||||
if thread["type"] == ThreadType.USER
|
||||
else thread["id"],
|
||||
"thread_id": client.id if thread["type"] == None else thread["id"],
|
||||
"thread_type": thread["type"],
|
||||
}
|
||||
d.update(kwargs)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from os import path
|
||||
from fbchat import ThreadType, Message, Mention, EmojiSize, Sticker
|
||||
from fbchat import Message, Mention, EmojiSize, Sticker
|
||||
from utils import subset, STICKER_LIST, EMOJI_LIST
|
||||
|
||||
pytestmark = pytest.mark.online
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from fbchat import Plan, FBchatFacebookError, ThreadType
|
||||
from fbchat import Plan, FBchatFacebookError
|
||||
from utils import random_hex, subset
|
||||
from time import time
|
||||
|
||||
@@ -93,7 +93,7 @@ def test_on_plan_ended(client, thread, catch_event, compare):
|
||||
x.wait(180)
|
||||
assert subset(
|
||||
x.res,
|
||||
thread_id=client.id if thread["type"] == ThreadType.USER else thread["id"],
|
||||
thread_id=client.id if thread["type"] is None else thread["id"],
|
||||
thread_type=thread["type"],
|
||||
)
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from fbchat import Poll, PollOption, ThreadType
|
||||
from fbchat import Poll, PollOption
|
||||
from utils import random_hex, subset
|
||||
|
||||
pytestmark = pytest.mark.online
|
||||
@@ -49,12 +49,7 @@ def poll_data(request, client1, group, catch_event):
|
||||
|
||||
def test_create_poll(client1, group, catch_event, poll_data):
|
||||
event, poll, _ = poll_data
|
||||
assert subset(
|
||||
event,
|
||||
author_id=client1.id,
|
||||
thread_id=group["id"],
|
||||
thread_type=ThreadType.GROUP,
|
||||
)
|
||||
assert subset(event, author_id=client1.id, thread=group)
|
||||
assert subset(
|
||||
vars(event["poll"]), title=poll.title, options_count=len(poll.options)
|
||||
)
|
||||
@@ -88,12 +83,7 @@ def test_update_poll_vote(client1, group, catch_event, poll_data):
|
||||
new_options=new_options,
|
||||
)
|
||||
|
||||
assert subset(
|
||||
x.res,
|
||||
author_id=client1.id,
|
||||
thread_id=group["id"],
|
||||
thread_type=ThreadType.GROUP,
|
||||
)
|
||||
assert subset(x.res, author_id=client1.id, thread=group)
|
||||
assert subset(
|
||||
vars(x.res["poll"]), title=poll.title, options_count=len(options + new_options)
|
||||
)
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import pytest
|
||||
from fbchat import ThreadType
|
||||
|
||||
pytestmark = pytest.mark.online
|
||||
|
||||
|
@@ -1,12 +1,6 @@
|
||||
import pytest
|
||||
import fbchat
|
||||
from fbchat import ThreadType, ThreadColor, ThreadABC, Thread
|
||||
|
||||
|
||||
def test_thread_type_to_class():
|
||||
assert fbchat.User == ThreadType.USER._to_class()
|
||||
assert fbchat.Group == ThreadType.GROUP._to_class()
|
||||
assert fbchat.Page == ThreadType.PAGE._to_class()
|
||||
from fbchat import ThreadColor, ThreadABC, Thread
|
||||
|
||||
|
||||
def test_thread_color_from_graphql():
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from fbchat import Message, ThreadType, FBchatFacebookError, TypingStatus, ThreadColor
|
||||
from fbchat import Message, FBchatFacebookError, TypingStatus, ThreadColor
|
||||
from utils import random_hex, subset
|
||||
from os import path
|
||||
|
||||
@@ -42,14 +42,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("on_title_change") as x:
|
||||
client1.change_thread_title(title, group["id"], thread_type=ThreadType.GROUP)
|
||||
assert subset(
|
||||
x.res,
|
||||
author_id=client1.id,
|
||||
new_title=title,
|
||||
thread_id=group["id"],
|
||||
thread_type=ThreadType.GROUP,
|
||||
)
|
||||
client1.change_thread_title(title, group["id"])
|
||||
assert subset(x.res, author_id=client1.id, new_title=title, thread=group)
|
||||
|
||||
|
||||
def test_change_nickname(client, client_all, catch_event, compare):
|
||||
|
@@ -5,7 +5,7 @@ import pytest
|
||||
from os import environ
|
||||
from random import randrange
|
||||
from contextlib import contextmanager
|
||||
from fbchat import ThreadType, EmojiSize, FBchatFacebookError, Sticker, Client
|
||||
from fbchat import EmojiSize, FBchatFacebookError, Sticker, Client
|
||||
|
||||
log = logging.getLogger("fbchat.tests").addHandler(logging.NullHandler())
|
||||
|
||||
|
Reference in New Issue
Block a user