Skip to content

Commit bc30a22

Browse files
authored
Merge pull request #262
MPT-19124 speed up tests
2 parents a2a7921 + d7bc467 commit bc30a22

File tree

15 files changed

+45
-44
lines changed

15 files changed

+45
-44
lines changed

tests/e2e/conftest.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,100 +10,101 @@
1010
from mpt_api_client import AsyncMPTClient, MPTClient
1111

1212

13-
@pytest.fixture
13+
@pytest.fixture(scope="session")
1414
def base_url():
1515
return os.getenv("MPT_API_BASE_URL")
1616

1717

18-
@pytest.fixture
18+
@pytest.fixture(scope="session")
1919
def api_timeout():
2020
return float(os.getenv("MPT_API_TIMEOUT", "60.0"))
2121

2222

23-
@pytest.fixture
23+
@pytest.fixture(scope="session")
2424
def mpt_vendor(base_url, api_timeout):
2525
return MPTClient.from_config(
2626
api_token=os.getenv("MPT_API_TOKEN_VENDOR"), base_url=base_url, timeout=api_timeout
2727
) # type: ignore
2828

2929

30-
@pytest.fixture
30+
@pytest.fixture(scope="session")
3131
def async_mpt_vendor(base_url, api_timeout):
3232
return AsyncMPTClient.from_config(
3333
api_token=os.getenv("MPT_API_TOKEN_VENDOR"), base_url=base_url, timeout=api_timeout
3434
) # type: ignore
3535

3636

37-
@pytest.fixture
37+
@pytest.fixture(scope="session")
3838
def mpt_ops(base_url, api_timeout):
3939
return MPTClient.from_config(
4040
api_token=os.getenv("MPT_API_TOKEN_OPERATIONS"), base_url=base_url, timeout=api_timeout
4141
) # type: ignore
4242

4343

44-
@pytest.fixture
44+
@pytest.fixture(scope="session")
4545
def async_mpt_ops(base_url, api_timeout):
4646
return AsyncMPTClient.from_config(
4747
api_token=os.getenv("MPT_API_TOKEN_OPERATIONS"), base_url=base_url, timeout=api_timeout
4848
) # type: ignore
4949

5050

51-
@pytest.fixture
51+
@pytest.fixture(scope="session")
5252
def mpt_client(base_url, api_timeout):
5353
return MPTClient.from_config(
5454
api_token=os.getenv("MPT_API_TOKEN_CLIENT"), base_url=base_url, timeout=api_timeout
5555
) # type: ignore
5656

5757

58-
@pytest.fixture
58+
@pytest.fixture(scope="session")
5959
def async_mpt_client(base_url, api_timeout):
6060
return AsyncMPTClient.from_config(
6161
api_token=os.getenv("MPT_API_TOKEN_CLIENT"), base_url=base_url, timeout=api_timeout
6262
) # type: ignore
6363

6464

65-
@pytest.fixture
65+
@pytest.fixture(scope="session")
6666
def rp_logger():
6767
logger = logging.getLogger(__name__)
6868
logger.setLevel(logging.DEBUG)
6969
logging.setLoggerClass(RPLogger)
7070
return logger
7171

7272

73-
@pytest.fixture
73+
@pytest.fixture(scope="session")
7474
def logger():
7575
return logging.getLogger("E2E")
7676

7777

78-
@pytest.fixture
78+
@pytest.fixture(scope="session")
7979
def project_root_path():
8080
return pathlib.Path(__file__).parent.parent.parent
8181

8282

83-
@pytest.fixture
83+
@pytest.fixture(scope="session")
8484
def pdf_fd():
8585
icon_path = pathlib.Path(__file__).parent / "empty.pdf"
86-
return pathlib.Path.open(icon_path, "rb")
86+
with pathlib.Path.open(icon_path, "rb") as fd:
87+
yield fd
8788

8889

89-
@pytest.fixture
90+
@pytest.fixture(scope="session")
9091
def pdf_url():
9192
return "https://sample-files.com/downloads/documents/pdf/basic-text.pdf"
9293

9394

94-
@pytest.fixture
95+
@pytest.fixture(scope="session")
9596
def jpg_url():
9697
return "https://sample-files.com/downloads/images/jpg/color_test_800x600_118kb.jpg"
9798

9899

99-
@pytest.fixture
100+
@pytest.fixture(scope="session")
100101
def e2e_config(project_root_path):
101102
filename = os.getenv("TEST_CONFIG_FILE", "e2e_config.test.json")
102103
file_path = project_root_path.joinpath(filename)
103104
return json.loads(file_path.read_text())
104105

105106

106-
@pytest.fixture
107+
@pytest.fixture(scope="session")
107108
def product_id(e2e_config):
108109
return e2e_config["catalog.product.id"]
109110

@@ -118,57 +119,57 @@ def uuid_str():
118119
return str(uuid.uuid4())
119120

120121

121-
@pytest.fixture
122+
@pytest.fixture(scope="session")
122123
def logo_fd(project_root_path):
123124
file_path = project_root_path / "tests/data/logo.png"
124125
return file_path.open("rb")
125126

126127

127-
@pytest.fixture
128+
@pytest.fixture(scope="session")
128129
def user_id(e2e_config):
129130
return e2e_config["accounts.user.id"]
130131

131132

132-
@pytest.fixture
133+
@pytest.fixture(scope="session")
133134
def account_id(e2e_config):
134135
return e2e_config["accounts.account.id"]
135136

136137

137-
@pytest.fixture
138+
@pytest.fixture(scope="session")
138139
def seller_id(e2e_config):
139140
return e2e_config["accounts.seller.id"]
140141

141142

142-
@pytest.fixture
143+
@pytest.fixture(scope="session")
143144
def buyer_id(e2e_config):
144145
return e2e_config["accounts.buyer.id"]
145146

146147

147-
@pytest.fixture
148+
@pytest.fixture(scope="session")
148149
def buyer_account_id(e2e_config):
149150
return e2e_config["accounts.buyer.account.id"]
150151

151152

152-
@pytest.fixture
153+
@pytest.fixture(scope="session")
153154
def licensee_id(e2e_config):
154155
return e2e_config["accounts.licensee.id"]
155156

156157

157-
@pytest.fixture
158+
@pytest.fixture(scope="session")
158159
def authorization_id(e2e_config):
159160
return e2e_config["commerce.authorization.id"]
160161

161162

162-
@pytest.fixture
163+
@pytest.fixture(scope="session")
163164
def price_list_id(e2e_config):
164165
return e2e_config["catalog.price_list.id"]
165166

166167

167-
@pytest.fixture
168+
@pytest.fixture(scope="session")
168169
def user_group_id(e2e_config):
169170
return e2e_config["accounts.user_group.id"]
170171

171172

172-
@pytest.fixture
173+
@pytest.fixture(scope="session")
173174
def commerce_product_id(e2e_config):
174175
return e2e_config["commerce.product.id"]

tests/e2e/helpdesk/cases/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33

4-
@pytest.fixture
4+
@pytest.fixture(scope="session")
55
def invalid_case_id():
66
return "CAS-0000-0000"
77

tests/e2e/helpdesk/channels/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
)
77

88

9-
@pytest.fixture
9+
@pytest.fixture(scope="session")
1010
def channel_id(e2e_config):
1111
return e2e_config["helpdesk.channel.id"] # FIXME: seed data
1212

1313

14-
@pytest.fixture
14+
@pytest.fixture(scope="session")
1515
def invalid_channel_id():
1616
return "CHN-0000-0000-0000"
1717

tests/e2e/helpdesk/chats/answers/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ async def async_created_chat_answer(async_chat_answers_service, chat_answer_data
3737
yield chat_answer
3838

3939

40-
@pytest.fixture
40+
@pytest.fixture(scope="session")
4141
def invalid_chat_answer_id():
4242
return "ANS-0000-0000"

tests/e2e/helpdesk/chats/answers/parameters/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def async_chat_answer_parameters_service(async_mpt_ops, chat_id, async_created_c
1111
return async_mpt_ops.helpdesk.chats.answers(chat_id).parameters(async_created_chat_answer.id)
1212

1313

14-
@pytest.fixture
14+
@pytest.fixture(scope="session")
1515
def invalid_chat_answer_parameter_id():
1616
return "PAR-0000-0000"

tests/e2e/helpdesk/chats/attachment/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ async def async_created_chat_attachment(
4848
)
4949

5050

51-
@pytest.fixture
51+
@pytest.fixture(scope="session")
5252
def invalid_chat_attachment_id():
5353
return "ATT-0000-0000-0000-0000"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pytest
22

33

4-
@pytest.fixture
4+
@pytest.fixture(scope="session")
55
def chat_id(e2e_config):
66
return e2e_config["helpdesk.chat.id"]
77

88

9-
@pytest.fixture
9+
@pytest.fixture(scope="session")
1010
def invalid_chat_id():
1111
return "CHT-0000-0000-0000"

tests/e2e/helpdesk/chats/links/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ async def async_created_chat_link(async_chat_links_service, chat_link_data):
3838
yield chat_link
3939

4040

41-
@pytest.fixture
41+
@pytest.fixture(scope="session")
4242
def invalid_chat_link_id():
4343
return "LNK-0000-0000-0000"

tests/e2e/helpdesk/chats/messages/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ async def async_created_chat_message(async_chat_messages_service, chat_message_d
3939
yield chat_message
4040

4141

42-
@pytest.fixture
42+
@pytest.fixture(scope="session")
4343
def invalid_chat_message_id():
4444
return "MSG-0000-0000-0000"

tests/e2e/helpdesk/chats/participants/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ async def async_created_chat_participant(async_chat_participants_service, chat_p
4040
yield chat_participant
4141

4242

43-
@pytest.fixture
43+
@pytest.fixture(scope="session")
4444
def invalid_chat_participant_id():
4545
return "CHP-0000-0000-0000"

0 commit comments

Comments
 (0)