1010from mpt_api_client import AsyncMPTClient , MPTClient
1111
1212
13- @pytest .fixture
13+ @pytest .fixture ( scope = "session" )
1414def base_url ():
1515 return os .getenv ("MPT_API_BASE_URL" )
1616
1717
18- @pytest .fixture
18+ @pytest .fixture ( scope = "session" )
1919def api_timeout ():
2020 return float (os .getenv ("MPT_API_TIMEOUT" , "60.0" ))
2121
2222
23- @pytest .fixture
23+ @pytest .fixture ( scope = "session" )
2424def 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" )
3131def 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" )
3838def 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" )
4545def 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" )
5252def 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" )
5959def 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" )
6666def 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" )
7474def logger ():
7575 return logging .getLogger ("E2E" )
7676
7777
78- @pytest .fixture
78+ @pytest .fixture ( scope = "session" )
7979def project_root_path ():
8080 return pathlib .Path (__file__ ).parent .parent .parent
8181
8282
83- @pytest .fixture
83+ @pytest .fixture ( scope = "session" )
8484def 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" )
9091def pdf_url ():
9192 return "https://sample-files.com/downloads/documents/pdf/basic-text.pdf"
9293
9394
94- @pytest .fixture
95+ @pytest .fixture ( scope = "session" )
9596def 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" )
100101def 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" )
107108def 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" )
122123def 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" )
128129def user_id (e2e_config ):
129130 return e2e_config ["accounts.user.id" ]
130131
131132
132- @pytest .fixture
133+ @pytest .fixture ( scope = "session" )
133134def account_id (e2e_config ):
134135 return e2e_config ["accounts.account.id" ]
135136
136137
137- @pytest .fixture
138+ @pytest .fixture ( scope = "session" )
138139def seller_id (e2e_config ):
139140 return e2e_config ["accounts.seller.id" ]
140141
141142
142- @pytest .fixture
143+ @pytest .fixture ( scope = "session" )
143144def buyer_id (e2e_config ):
144145 return e2e_config ["accounts.buyer.id" ]
145146
146147
147- @pytest .fixture
148+ @pytest .fixture ( scope = "session" )
148149def buyer_account_id (e2e_config ):
149150 return e2e_config ["accounts.buyer.account.id" ]
150151
151152
152- @pytest .fixture
153+ @pytest .fixture ( scope = "session" )
153154def licensee_id (e2e_config ):
154155 return e2e_config ["accounts.licensee.id" ]
155156
156157
157- @pytest .fixture
158+ @pytest .fixture ( scope = "session" )
158159def authorization_id (e2e_config ):
159160 return e2e_config ["commerce.authorization.id" ]
160161
161162
162- @pytest .fixture
163+ @pytest .fixture ( scope = "session" )
163164def price_list_id (e2e_config ):
164165 return e2e_config ["catalog.price_list.id" ]
165166
166167
167- @pytest .fixture
168+ @pytest .fixture ( scope = "session" )
168169def user_group_id (e2e_config ):
169170 return e2e_config ["accounts.user_group.id" ]
170171
171172
172- @pytest .fixture
173+ @pytest .fixture ( scope = "session" )
173174def commerce_product_id (e2e_config ):
174175 return e2e_config ["commerce.product.id" ]
0 commit comments