diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index dedec67c..92b01d72 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -10,59 +10,59 @@ from mpt_api_client import AsyncMPTClient, MPTClient -@pytest.fixture +@pytest.fixture(scope="session") def base_url(): return os.getenv("MPT_API_BASE_URL") -@pytest.fixture +@pytest.fixture(scope="session") def api_timeout(): return float(os.getenv("MPT_API_TIMEOUT", "60.0")) -@pytest.fixture +@pytest.fixture(scope="session") def mpt_vendor(base_url, api_timeout): return MPTClient.from_config( api_token=os.getenv("MPT_API_TOKEN_VENDOR"), base_url=base_url, timeout=api_timeout ) # type: ignore -@pytest.fixture +@pytest.fixture(scope="session") def async_mpt_vendor(base_url, api_timeout): return AsyncMPTClient.from_config( api_token=os.getenv("MPT_API_TOKEN_VENDOR"), base_url=base_url, timeout=api_timeout ) # type: ignore -@pytest.fixture +@pytest.fixture(scope="session") def mpt_ops(base_url, api_timeout): return MPTClient.from_config( api_token=os.getenv("MPT_API_TOKEN_OPERATIONS"), base_url=base_url, timeout=api_timeout ) # type: ignore -@pytest.fixture +@pytest.fixture(scope="session") def async_mpt_ops(base_url, api_timeout): return AsyncMPTClient.from_config( api_token=os.getenv("MPT_API_TOKEN_OPERATIONS"), base_url=base_url, timeout=api_timeout ) # type: ignore -@pytest.fixture +@pytest.fixture(scope="session") def mpt_client(base_url, api_timeout): return MPTClient.from_config( api_token=os.getenv("MPT_API_TOKEN_CLIENT"), base_url=base_url, timeout=api_timeout ) # type: ignore -@pytest.fixture +@pytest.fixture(scope="session") def async_mpt_client(base_url, api_timeout): return AsyncMPTClient.from_config( api_token=os.getenv("MPT_API_TOKEN_CLIENT"), base_url=base_url, timeout=api_timeout ) # type: ignore -@pytest.fixture +@pytest.fixture(scope="session") def rp_logger(): logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) @@ -70,40 +70,41 @@ def rp_logger(): return logger -@pytest.fixture +@pytest.fixture(scope="session") def logger(): return logging.getLogger("E2E") -@pytest.fixture +@pytest.fixture(scope="session") def project_root_path(): return pathlib.Path(__file__).parent.parent.parent -@pytest.fixture +@pytest.fixture(scope="session") def pdf_fd(): icon_path = pathlib.Path(__file__).parent / "empty.pdf" - return pathlib.Path.open(icon_path, "rb") + with pathlib.Path.open(icon_path, "rb") as fd: + yield fd -@pytest.fixture +@pytest.fixture(scope="session") def pdf_url(): return "https://sample-files.com/downloads/documents/pdf/basic-text.pdf" -@pytest.fixture +@pytest.fixture(scope="session") def jpg_url(): return "https://sample-files.com/downloads/images/jpg/color_test_800x600_118kb.jpg" -@pytest.fixture +@pytest.fixture(scope="session") def e2e_config(project_root_path): filename = os.getenv("TEST_CONFIG_FILE", "e2e_config.test.json") file_path = project_root_path.joinpath(filename) return json.loads(file_path.read_text()) -@pytest.fixture +@pytest.fixture(scope="session") def product_id(e2e_config): return e2e_config["catalog.product.id"] @@ -118,57 +119,57 @@ def uuid_str(): return str(uuid.uuid4()) -@pytest.fixture +@pytest.fixture(scope="session") def logo_fd(project_root_path): file_path = project_root_path / "tests/data/logo.png" return file_path.open("rb") -@pytest.fixture +@pytest.fixture(scope="session") def user_id(e2e_config): return e2e_config["accounts.user.id"] -@pytest.fixture +@pytest.fixture(scope="session") def account_id(e2e_config): return e2e_config["accounts.account.id"] -@pytest.fixture +@pytest.fixture(scope="session") def seller_id(e2e_config): return e2e_config["accounts.seller.id"] -@pytest.fixture +@pytest.fixture(scope="session") def buyer_id(e2e_config): return e2e_config["accounts.buyer.id"] -@pytest.fixture +@pytest.fixture(scope="session") def buyer_account_id(e2e_config): return e2e_config["accounts.buyer.account.id"] -@pytest.fixture +@pytest.fixture(scope="session") def licensee_id(e2e_config): return e2e_config["accounts.licensee.id"] -@pytest.fixture +@pytest.fixture(scope="session") def authorization_id(e2e_config): return e2e_config["commerce.authorization.id"] -@pytest.fixture +@pytest.fixture(scope="session") def price_list_id(e2e_config): return e2e_config["catalog.price_list.id"] -@pytest.fixture +@pytest.fixture(scope="session") def user_group_id(e2e_config): return e2e_config["accounts.user_group.id"] -@pytest.fixture +@pytest.fixture(scope="session") def commerce_product_id(e2e_config): return e2e_config["commerce.product.id"] diff --git a/tests/e2e/helpdesk/cases/conftest.py b/tests/e2e/helpdesk/cases/conftest.py index ba66094f..97f54ee1 100644 --- a/tests/e2e/helpdesk/cases/conftest.py +++ b/tests/e2e/helpdesk/cases/conftest.py @@ -1,7 +1,7 @@ import pytest -@pytest.fixture +@pytest.fixture(scope="session") def invalid_case_id(): return "CAS-0000-0000" diff --git a/tests/e2e/helpdesk/channels/conftest.py b/tests/e2e/helpdesk/channels/conftest.py index 19bf2235..321e0668 100644 --- a/tests/e2e/helpdesk/channels/conftest.py +++ b/tests/e2e/helpdesk/channels/conftest.py @@ -6,12 +6,12 @@ ) -@pytest.fixture +@pytest.fixture(scope="session") def channel_id(e2e_config): return e2e_config["helpdesk.channel.id"] # FIXME: seed data -@pytest.fixture +@pytest.fixture(scope="session") def invalid_channel_id(): return "CHN-0000-0000-0000" diff --git a/tests/e2e/helpdesk/chats/answers/conftest.py b/tests/e2e/helpdesk/chats/answers/conftest.py index 69bdf227..f8c10d90 100644 --- a/tests/e2e/helpdesk/chats/answers/conftest.py +++ b/tests/e2e/helpdesk/chats/answers/conftest.py @@ -37,6 +37,6 @@ async def async_created_chat_answer(async_chat_answers_service, chat_answer_data yield chat_answer -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_answer_id(): return "ANS-0000-0000" diff --git a/tests/e2e/helpdesk/chats/answers/parameters/conftest.py b/tests/e2e/helpdesk/chats/answers/parameters/conftest.py index cebf39ce..8205bd8a 100644 --- a/tests/e2e/helpdesk/chats/answers/parameters/conftest.py +++ b/tests/e2e/helpdesk/chats/answers/parameters/conftest.py @@ -11,6 +11,6 @@ def async_chat_answer_parameters_service(async_mpt_ops, chat_id, async_created_c return async_mpt_ops.helpdesk.chats.answers(chat_id).parameters(async_created_chat_answer.id) -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_answer_parameter_id(): return "PAR-0000-0000" diff --git a/tests/e2e/helpdesk/chats/attachment/conftest.py b/tests/e2e/helpdesk/chats/attachment/conftest.py index 5b09f173..cff46a34 100644 --- a/tests/e2e/helpdesk/chats/attachment/conftest.py +++ b/tests/e2e/helpdesk/chats/attachment/conftest.py @@ -48,6 +48,6 @@ async def async_created_chat_attachment( ) -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_attachment_id(): return "ATT-0000-0000-0000-0000" diff --git a/tests/e2e/helpdesk/chats/conftest.py b/tests/e2e/helpdesk/chats/conftest.py index 2637d735..2a772443 100644 --- a/tests/e2e/helpdesk/chats/conftest.py +++ b/tests/e2e/helpdesk/chats/conftest.py @@ -1,11 +1,11 @@ import pytest -@pytest.fixture +@pytest.fixture(scope="session") def chat_id(e2e_config): return e2e_config["helpdesk.chat.id"] -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_id(): return "CHT-0000-0000-0000" diff --git a/tests/e2e/helpdesk/chats/links/conftest.py b/tests/e2e/helpdesk/chats/links/conftest.py index 2729c934..001885e1 100644 --- a/tests/e2e/helpdesk/chats/links/conftest.py +++ b/tests/e2e/helpdesk/chats/links/conftest.py @@ -38,6 +38,6 @@ async def async_created_chat_link(async_chat_links_service, chat_link_data): yield chat_link -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_link_id(): return "LNK-0000-0000-0000" diff --git a/tests/e2e/helpdesk/chats/messages/conftest.py b/tests/e2e/helpdesk/chats/messages/conftest.py index 43ebbba1..71949546 100644 --- a/tests/e2e/helpdesk/chats/messages/conftest.py +++ b/tests/e2e/helpdesk/chats/messages/conftest.py @@ -39,6 +39,6 @@ async def async_created_chat_message(async_chat_messages_service, chat_message_d yield chat_message -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_message_id(): return "MSG-0000-0000-0000" diff --git a/tests/e2e/helpdesk/chats/participants/conftest.py b/tests/e2e/helpdesk/chats/participants/conftest.py index a3c191c8..21f1deaa 100644 --- a/tests/e2e/helpdesk/chats/participants/conftest.py +++ b/tests/e2e/helpdesk/chats/participants/conftest.py @@ -40,6 +40,6 @@ async def async_created_chat_participant(async_chat_participants_service, chat_p yield chat_participant -@pytest.fixture +@pytest.fixture(scope="session") def invalid_chat_participant_id(): return "CHP-0000-0000-0000" diff --git a/tests/e2e/helpdesk/forms/conftest.py b/tests/e2e/helpdesk/forms/conftest.py index 2e7cf612..0e019cd3 100644 --- a/tests/e2e/helpdesk/forms/conftest.py +++ b/tests/e2e/helpdesk/forms/conftest.py @@ -14,7 +14,7 @@ def form_data(short_uuid): } -@pytest.fixture +@pytest.fixture(scope="session") def invalid_form_id(): return "FRM-0000-0000" diff --git a/tests/e2e/helpdesk/parameter_groups/conftest.py b/tests/e2e/helpdesk/parameter_groups/conftest.py index 7e565374..067235cd 100644 --- a/tests/e2e/helpdesk/parameter_groups/conftest.py +++ b/tests/e2e/helpdesk/parameter_groups/conftest.py @@ -15,7 +15,7 @@ def parameter_group_data(short_uuid): } -@pytest.fixture +@pytest.fixture(scope="session") def invalid_parameter_group_id(): return "PGR-0000-0000" diff --git a/tests/e2e/helpdesk/parameter_groups/parameters/conftest.py b/tests/e2e/helpdesk/parameter_groups/parameters/conftest.py index 82807923..5601ff0c 100644 --- a/tests/e2e/helpdesk/parameter_groups/parameters/conftest.py +++ b/tests/e2e/helpdesk/parameter_groups/parameters/conftest.py @@ -63,7 +63,7 @@ def created_parameter_group_parameter( yield parameter_group_parameter -@pytest.fixture +@pytest.fixture(scope="session") def invalid_parameter_group_parameter_id(): return "PAR-0000-0000" diff --git a/tests/e2e/helpdesk/parameters/conftest.py b/tests/e2e/helpdesk/parameters/conftest.py index 1dc3059a..0e732e46 100644 --- a/tests/e2e/helpdesk/parameters/conftest.py +++ b/tests/e2e/helpdesk/parameters/conftest.py @@ -24,7 +24,7 @@ def parameter_data(short_uuid): } -@pytest.fixture +@pytest.fixture(scope="session") def invalid_parameter_id(): return "PAR-0000-0000" diff --git a/tests/e2e/helpdesk/queues/conftest.py b/tests/e2e/helpdesk/queues/conftest.py index 6dfa9849..dfefff60 100644 --- a/tests/e2e/helpdesk/queues/conftest.py +++ b/tests/e2e/helpdesk/queues/conftest.py @@ -15,7 +15,7 @@ def queue_data(short_uuid): } -@pytest.fixture +@pytest.fixture(scope="session") def invalid_queue_id(): return "HQU-0000-0000"