33from unittest .mock import patch
44from pubnub .pubnub_asyncio import PubNubAsyncio
55from tests .integrational .vcr_helper import pn_vcr
6- from tests .helper import pnconf_file_copy , pnconf_enc_env_copy
6+ from tests .helper import pnconf_env_copy , pnconf_enc_env_copy
77from pubnub .endpoints .file_operations .publish_file_message import PublishFileMessage
88from pubnub .models .consumer .file import (
99 PNSendFileResult , PNGetFilesResult , PNDownloadFileResult ,
@@ -33,12 +33,12 @@ async def send_file(pubnub, file_for_upload, cipher_key=None):
3333
3434
3535@pn_vcr .use_cassette (
36- "tests/integrational/fixtures/asyncio/file_upload/delete_file.yaml " ,
36+ "tests/integrational/fixtures/asyncio/file_upload/delete_file.json" , serializer = "pn_json " ,
3737 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ]
3838)
39- @pytest .mark .asyncio
40- async def test_delete_file (event_loop , file_for_upload ):
41- pubnub = PubNubAsyncio (pnconf_file_copy (), custom_event_loop = event_loop )
39+ @pytest .mark .asyncio ( loop_scope = "module" )
40+ async def test_delete_file (file_for_upload ):
41+ pubnub = PubNubAsyncio (pnconf_env_copy () )
4242 pubnub .config .uuid = "files_asyncio_uuid"
4343
4444 envelope = await send_file (pubnub , file_for_upload )
@@ -53,28 +53,26 @@ async def test_delete_file(event_loop, file_for_upload):
5353
5454
5555@pn_vcr .use_cassette (
56- "tests/integrational/fixtures/asyncio/file_upload/list_files.yaml " ,
56+ "tests/integrational/fixtures/asyncio/file_upload/list_files.json" , serializer = "pn_json " ,
5757 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ]
58-
59-
6058)
61- @pytest .mark .asyncio
62- async def test_list_files (event_loop ):
63- pubnub = PubNubAsyncio (pnconf_file_copy (), custom_event_loop = event_loop )
59+ @pytest .mark .asyncio ( loop_scope = "module" )
60+ async def test_list_files ():
61+ pubnub = PubNubAsyncio (pnconf_env_copy () )
6462 envelope = await pubnub .list_files ().channel (CHANNEL ).future ()
6563
6664 assert isinstance (envelope .result , PNGetFilesResult )
67- assert envelope .result .count == 23
65+ assert envelope .result .count == 7
6866 await pubnub .stop ()
6967
7068
7169@pn_vcr .use_cassette (
72- "tests/integrational/fixtures/asyncio/file_upload/send_and_download_file.yaml " ,
70+ "tests/integrational/fixtures/asyncio/file_upload/send_and_download_file.json" , serializer = "pn_json " ,
7371 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ]
7472)
75- @pytest .mark .asyncio
76- async def test_send_and_download_file (event_loop , file_for_upload ):
77- pubnub = PubNubAsyncio (pnconf_file_copy (), custom_event_loop = event_loop )
73+ @pytest .mark .asyncio ( loop_scope = "module" )
74+ async def test_send_and_download_file (file_for_upload ):
75+ pubnub = PubNubAsyncio (pnconf_env_copy () )
7876 envelope = await send_file (pubnub , file_for_upload )
7977 download_envelope = await pubnub .download_file ().\
8078 channel (CHANNEL ).\
@@ -89,9 +87,9 @@ async def test_send_and_download_file(event_loop, file_for_upload):
8987 "tests/integrational/fixtures/asyncio/file_upload/send_and_download_encrypted_file_cipher_key.json" ,
9088 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ], serializer = 'pn_json'
9189)
92- @pytest .mark .asyncio
93- async def test_send_and_download_file_encrypted_cipher_key (event_loop , file_for_upload , file_upload_test_data ):
94- pubnub = PubNubAsyncio (pnconf_enc_env_copy (), custom_event_loop = event_loop )
90+ @pytest .mark .asyncio ( loop_scope = "module" )
91+ async def test_send_and_download_file_encrypted_cipher_key (file_for_upload , file_upload_test_data ):
92+ pubnub = PubNubAsyncio (pnconf_enc_env_copy ())
9593
9694 with patch ("pubnub.crypto.PubNubCryptodome.get_initialization_vector" , return_value = "knightsofni12345" ):
9795 envelope = await send_file (pubnub , file_for_upload , cipher_key = "test" )
@@ -111,9 +109,9 @@ async def test_send_and_download_file_encrypted_cipher_key(event_loop, file_for_
111109 "tests/integrational/fixtures/asyncio/file_upload/send_and_download_encrypted_file_crypto_module.json" ,
112110 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ], serializer = 'pn_json'
113111)
114- @pytest .mark .asyncio
115- async def test_send_and_download_encrypted_file_crypto_module (event_loop , file_for_upload , file_upload_test_data ):
116- pubnub = PubNubAsyncio (pnconf_enc_env_copy (), custom_event_loop = event_loop )
112+ @pytest .mark .asyncio ( loop_scope = "module" )
113+ async def test_send_and_download_encrypted_file_crypto_module (file_for_upload , file_upload_test_data ):
114+ pubnub = PubNubAsyncio (pnconf_enc_env_copy ())
117115
118116 with patch ("pubnub.crypto_core.PubNubLegacyCryptor.get_initialization_vector" , return_value = b"knightsofni12345" ):
119117 envelope = await send_file (pubnub , file_for_upload )
@@ -129,12 +127,12 @@ async def test_send_and_download_encrypted_file_crypto_module(event_loop, file_f
129127
130128
131129@pn_vcr .use_cassette (
132- "tests/integrational/fixtures/asyncio/file_upload/get_file_url.yaml " ,
130+ "tests/integrational/fixtures/asyncio/file_upload/get_file_url.json" , serializer = "pn_json " ,
133131 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ]
134132)
135- @pytest .mark .asyncio
136- async def test_get_file_url (event_loop , file_for_upload ):
137- pubnub = PubNubAsyncio (pnconf_file_copy (), custom_event_loop = event_loop )
133+ @pytest .mark .asyncio ( loop_scope = "module" )
134+ async def test_get_file_url (file_for_upload ):
135+ pubnub = PubNubAsyncio (pnconf_env_copy () )
138136 envelope = await send_file (pubnub , file_for_upload )
139137 file_url_envelope = await pubnub .get_file_url ().\
140138 channel (CHANNEL ).\
@@ -146,12 +144,12 @@ async def test_get_file_url(event_loop, file_for_upload):
146144
147145
148146@pn_vcr .use_cassette (
149- "tests/integrational/fixtures/asyncio/file_upload/fetch_s3_upload_data.yaml " ,
147+ "tests/integrational/fixtures/asyncio/file_upload/fetch_s3_upload_data.json" , serializer = "pn_json " ,
150148 filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ]
151149)
152- @pytest .mark .asyncio
153- async def test_fetch_file_upload_s3_data_with_result_invocation (event_loop , file_upload_test_data ):
154- pubnub = PubNubAsyncio (pnconf_file_copy (), custom_event_loop = event_loop )
150+ @pytest .mark .asyncio ( loop_scope = "module" )
151+ async def test_fetch_file_upload_s3_data_with_result_invocation (file_upload_test_data ):
152+ pubnub = PubNubAsyncio (pnconf_env_copy () )
155153 result = await pubnub ._fetch_file_upload_s3_data ().\
156154 channel (CHANNEL ).\
157155 file_name (file_upload_test_data ["UPLOADED_FILENAME" ]).result ()
@@ -161,12 +159,12 @@ async def test_fetch_file_upload_s3_data_with_result_invocation(event_loop, file
161159
162160
163161@pn_vcr .use_cassette (
164- "tests/integrational/fixtures/asyncio/file_upload/publish_file_message_encrypted.yaml " ,
162+ "tests/integrational/fixtures/asyncio/file_upload/publish_file_message_encrypted.json" , serializer = "pn_json " ,
165163 filter_query_parameters = ['uuid' , 'seqn' , 'pnsdk' ]
166164)
167- @pytest .mark .asyncio
168- async def test_publish_file_message_with_encryption (event_loop , file_upload_test_data ):
169- pubnub = PubNubAsyncio (pnconf_file_copy (), custom_event_loop = event_loop )
165+ @pytest .mark .asyncio ( loop_scope = "module" )
166+ async def test_publish_file_message_with_encryption (file_upload_test_data ):
167+ pubnub = PubNubAsyncio (pnconf_env_copy () )
170168 envelope = await PublishFileMessage (pubnub ).\
171169 channel (CHANNEL ).\
172170 meta ({}).\
0 commit comments