From d06ff7078a4c4138bb874541a4b3c9821c340aae Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 8 Sep 2019 23:27:06 +0200 Subject: [PATCH] Mark existing tests as `online` - Remove `offline` and `expensive` markers --- .travis.yml | 2 +- pytest.ini | 5 ++--- tests/test_base.py | 4 ++-- tests/test_fetch.py | 2 ++ tests/test_message_management.py | 2 ++ tests/test_plans.py | 4 +++- tests/test_polls.py | 2 ++ tests/test_search.py | 3 +++ tests/test_send.py | 2 ++ tests/test_tests.py | 2 ++ tests/test_thread_interraction.py | 9 +++------ 11 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00c5228..f63d7ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ cache: pip before_install: pip install flit # Use `--deps production` so that we don't install unnecessary dependencies install: flit install --deps production --extras test -script: pytest -m offline +script: pytest jobs: include: diff --git a/pytest.ini b/pytest.ini index 1ac6d3a..41b9983 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,10 +1,9 @@ [pytest] xfail_strict = true markers = - offline: Offline tests, aka. tests that can be executed without the need of a client - expensive: Expensive tests, which should be executed sparingly + online: Online tests, aka. disabled tests... addopts = --strict-markers - -m "not expensive" + -m "not online" testpaths = tests filterwarnings = error diff --git a/tests/test_base.py b/tests/test_base.py index ebd2a79..fd23ab3 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -6,7 +6,6 @@ from os import path, environ from fbchat import FBchatException, Message, Client -@pytest.mark.offline def test_examples(): # Compiles the examples, to check for syntax errors for name in glob(path.join(path.dirname(__file__), "../examples", "*.py")): @@ -14,7 +13,7 @@ def test_examples(): @pytest.mark.trylast -@pytest.mark.expensive +@pytest.mark.online def test_login(client1): assert client1.is_logged_in() email = client1.email @@ -33,6 +32,7 @@ def test_login(client1): @pytest.mark.trylast +@pytest.mark.online def test_sessions(client1): session = client1.get_session() Client("no email needed", "no password needed", session_cookies=session) diff --git a/tests/test_fetch.py b/tests/test_fetch.py index ee86f6e..32c0196 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -4,6 +4,8 @@ from os import path from fbchat import ThreadType, Message, Mention, EmojiSize, Sticker from utils import subset, STICKER_LIST, EMOJI_LIST +pytestmark = pytest.mark.online + def test_fetch_all_users(client1): users = client1.fetch_all_users() diff --git a/tests/test_message_management.py b/tests/test_message_management.py index 83a12bd..849a26a 100644 --- a/tests/test_message_management.py +++ b/tests/test_message_management.py @@ -3,6 +3,8 @@ import pytest from fbchat import Message, MessageReaction from utils import subset +pytestmark = pytest.mark.online + def test_set_reaction(client): mid = client.send(Message(text="This message will be reacted to")) diff --git a/tests/test_plans.py b/tests/test_plans.py index bd762c2..12807ee 100644 --- a/tests/test_plans.py +++ b/tests/test_plans.py @@ -4,6 +4,8 @@ from fbchat import Plan, FBchatFacebookError, ThreadType from utils import random_hex, subset from time import time +pytestmark = pytest.mark.online + @pytest.fixture( scope="module", @@ -84,7 +86,7 @@ def test_edit_plan(client, thread, catch_event, compare, plan_data): @pytest.mark.trylast -@pytest.mark.expensive +@pytest.mark.skip def test_on_plan_ended(client, thread, catch_event, compare): with catch_event("on_plan_ended") as x: client.create_plan(Plan(int(time()) + 120, "Wait for ending")) diff --git a/tests/test_polls.py b/tests/test_polls.py index d4ffb24..a6913c4 100644 --- a/tests/test_polls.py +++ b/tests/test_polls.py @@ -3,6 +3,8 @@ import pytest from fbchat import Poll, PollOption, ThreadType from utils import random_hex, subset +pytestmark = pytest.mark.online + @pytest.fixture( scope="module", diff --git a/tests/test_search.py b/tests/test_search.py index 54c9cc6..82f6471 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1,5 +1,8 @@ +import pytest from fbchat import ThreadType +pytestmark = pytest.mark.online + def test_search_for(client1): users = client1.search_for_users("Mark Zuckerberg") diff --git a/tests/test_send.py b/tests/test_send.py index fa5f3fa..2a9d5aa 100644 --- a/tests/test_send.py +++ b/tests/test_send.py @@ -4,6 +4,8 @@ from os import path from fbchat import FBchatFacebookError, Message, Mention from utils import subset, STICKER_LIST, EMOJI_LIST, TEXT_LIST +pytestmark = pytest.mark.online + @pytest.mark.parametrize("text", TEXT_LIST) def test_send_text(client, catch_event, compare, text): diff --git a/tests/test_tests.py b/tests/test_tests.py index 23f32f7..180d0b7 100644 --- a/tests/test_tests.py +++ b/tests/test_tests.py @@ -1,5 +1,7 @@ import pytest +pytestmark = pytest.mark.online + def test_catch_event(client2, catch_event): mid = "test" diff --git a/tests/test_thread_interraction.py b/tests/test_thread_interraction.py index 34dac97..b9d42a4 100644 --- a/tests/test_thread_interraction.py +++ b/tests/test_thread_interraction.py @@ -4,6 +4,8 @@ from fbchat import Message, ThreadType, FBchatFacebookError, TypingStatus, Threa from utils import random_hex, subset from os import path +pytestmark = pytest.mark.online + 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 @@ -97,12 +99,7 @@ def test_change_image_remote(client1, group, catch_event): @pytest.mark.parametrize( "color", - [ - x - if x in [ThreadColor.MESSENGER_BLUE, ThreadColor.PUMPKIN] - else pytest.param(x, marks=[pytest.mark.expensive()]) - for x in ThreadColor - ], + [x for x in ThreadColor if x in [ThreadColor.MESSENGER_BLUE, ThreadColor.PUMPKIN]], ) def test_change_color(client, catch_event, compare, color): with catch_event("on_color_change") as x: