@@ -57,12 +57,87 @@ async def test_delete_file(file_for_upload):
5757    filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ] 
5858) 
5959@pytest .mark .asyncio (loop_scope = "module" ) 
60- async  def  test_list_files ():
60+ async  def  test_list_files (file_for_upload ,  file_upload_test_data ):
6161    pubnub  =  PubNubAsyncio (pnconf_env_copy ())
62+     pubnub .config .uuid  =  "files_asyncio_uuid" 
63+ 
64+     # Clear existing files first to ensure a clean state 
65+     envelope  =  await  pubnub .list_files ().channel (CHANNEL ).future ()
66+     files  =  envelope .result .data 
67+     for  i  in  range (len (files )):
68+         file  =  files [i ]
69+         await  pubnub .delete_file ().channel (CHANNEL ).file_id (file ["id" ]).file_name (file ["name" ]).future ()
70+ 
71+     envelope  =  await  send_file (pubnub , file_for_upload )
72+ 
73+     envelope  =  await  pubnub .list_files ().channel (CHANNEL ).future ()
74+ 
75+     assert  isinstance (envelope .result , PNGetFilesResult )
76+     assert  envelope .result .count  ==  1 
77+     assert  file_upload_test_data ["UPLOADED_FILENAME" ] ==  envelope .result .data [0 ]["name" ]
78+     await  pubnub .stop ()
79+ 
80+ 
81+ @pn_vcr .use_cassette ( 
82+     "tests/integrational/fixtures/asyncio/file_upload/list_files_with_limit.json" , serializer = "pn_json" , 
83+     filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ] 
84+ ) 
85+ @pytest .mark .asyncio (loop_scope = "module" ) 
86+ async  def  test_list_files_with_limit (file_for_upload , file_upload_test_data ):
87+     pubnub  =  PubNubAsyncio (pnconf_env_copy ())
88+     pubnub .config .uuid  =  "files_asyncio_uuid" 
89+     await  send_file (pubnub , file_for_upload )
90+     await  send_file (pubnub , file_for_upload )
91+     envelope  =  await  pubnub .list_files ().channel (CHANNEL ).limit (2 ).future ()
92+     assert  isinstance (envelope .result , PNGetFilesResult )
93+     assert  envelope .result .count  ==  2 
94+     assert  file_upload_test_data ["UPLOADED_FILENAME" ] ==  envelope .result .data [0 ]["name" ]
95+     await  pubnub .stop ()
96+ 
97+ 
98+ @pn_vcr .use_cassette ( 
99+     "tests/integrational/fixtures/asyncio/file_upload/list_files_with_page.json" , serializer = "pn_json" , 
100+     filter_query_parameters = ['uuid' , 'l_file' , 'pnsdk' ] 
101+ ) 
102+ @pytest .mark .asyncio (loop_scope = "module" ) 
103+ async  def  test_list_files_with_page (file_for_upload , file_upload_test_data ):
104+     pubnub  =  PubNubAsyncio (pnconf_env_copy ())
105+     pubnub .config .uuid  =  "files_asyncio_uuid" 
106+     await  send_file (pubnub , file_for_upload )
107+     await  send_file (pubnub , file_for_upload )
108+     envelope  =  await  pubnub .list_files ().channel (CHANNEL ).limit (2 ).future ()
109+     assert  isinstance (envelope .result , PNGetFilesResult )
110+     assert  envelope .result .count  ==  2 
111+     assert  envelope .result .next  is  not None 
112+     next_page  =  envelope .result .next 
113+     file_ids  =  [envelope .result .data [0 ]['id' ], envelope .result .data [1 ]['id' ]]
114+     envelope  =  await  pubnub .list_files ().channel (CHANNEL ).limit (2 ).next (next_page ).future ()
115+     assert  isinstance (envelope .result , PNGetFilesResult )
116+     assert  envelope .result .count  ==  2 
117+     assert  envelope .result .next  is  not None 
118+     assert  envelope .result .data [0 ]['id' ] not  in file_ids 
119+     assert  envelope .result .data [1 ]['id' ] not  in file_ids 
120+     assert  file_upload_test_data ["UPLOADED_FILENAME" ] ==  envelope .result .data [0 ]["name" ]
121+     await  pubnub .stop ()
122+ 
123+ 
124+ # @pn_vcr.use_cassette( # Needs new recording for asyncio 
125+ #     "tests/integrational/fixtures/asyncio/file_upload/delete_all_files.json", serializer="pn_json", 
126+ #     filter_query_parameters=['uuid', 'l_file', 'pnsdk'] 
127+ # ) 
128+ @pytest .mark .asyncio (loop_scope = "module" ) 
129+ async  def  test_delete_all_files ():
130+     pubnub  =  PubNubAsyncio (pnconf_env_copy ())
131+     pubnub .config .uuid  =  "files_asyncio_uuid" 
132+     envelope  =  await  pubnub .list_files ().channel (CHANNEL ).future ()
133+     files  =  envelope .result .data 
134+     for  i  in  range (len (files )):
135+         file  =  files [i ]
136+         await  pubnub .delete_file ().channel (CHANNEL ).file_id (file ["id" ]).file_name (file ["name" ]).future ()
62137    envelope  =  await  pubnub .list_files ().channel (CHANNEL ).future ()
63138
64139    assert  isinstance (envelope .result , PNGetFilesResult )
65-     assert  envelope .result .count  ==  7 
140+     assert  envelope .result .count  ==  0 
66141    await  pubnub .stop ()
67142
68143
0 commit comments