@@ -350,6 +350,112 @@ def test_list_files_fails_on_unauthenticated_request(self) -> None:
350350 self .assertEqual ("Your account cannot be authenticated." , e .message )
351351 self .assertEqual (403 , e .response_metadata .http_status_code )
352352
353+ @responses .activate
354+ def test_list_files_succeeds_with_basic_request_tags_with_array (self ) -> None :
355+ """
356+ Tests if list_files work with options which contains type, sort, path, searchQuery, fileType, limit, skip and tags
357+ """
358+
359+ URL .API_BASE_URL = "http://test.com"
360+ url = "{}/v1/files" .format (URL .API_BASE_URL )
361+
362+ headers = create_headers_for_test ()
363+ responses .add (
364+ responses .GET ,
365+ url ,
366+ body = """[{
367+ "type": "file",
368+ "name": "sample-cat-image_gr64HPlJS.jpg",
369+ "createdAt": "2022-06-15T08:19:00.843Z",
370+ "updatedAt": "2022-06-15T08:19:45.169Z",
371+ "fileId": "62a995f4d875ec08dc587b72",
372+ "tags": ["{Tag_1", " Tag_2", " Tag_3}", "tag-to-add-2"],
373+ "AITags": "",
374+ "versionInfo": {
375+ "id": "62a995f4d875ec08dc587b72",
376+ "name": "Version 1"
377+ },
378+ "embeddedMetadata": {
379+ "XResolution": 250,
380+ "YResolution": 250,
381+ "DateCreated": "2022-06-15T08:19:01.523Z",
382+ "DateTimeCreated": "2022-06-15T08:19:01.524Z"
383+ },
384+ "customCoordinates": "10,10,20,20",
385+ "customMetadata": {
386+ "test100": 10
387+ },
388+ "isPrivateFile": false,
389+ "url": "https://ik.imagekit.io/your_imagekit_id/sample-cat-image_gr64HPlJS.jpg",
390+ "thumbnail": "https://ik.imagekit.io/your_imagekit_id/tr:n-ik_ml_thumbnail/sample-cat-image_gr64HPlJS.jpg",
391+ "fileType": "image",
392+ "filePath": "/sample-cat-image_gr64HPlJS.jpg",
393+ "height": 354,
394+ "width": 236,
395+ "size": 23023,
396+ "hasAlpha": false,
397+ "mime": "image/jpeg"
398+ }]""" ,
399+ headers = headers ,
400+ match = [
401+ matchers .query_string_matcher (
402+ "%7B%22type%22:%20%22file%22,%20%22sort%22:%20%22ASC_CREATED%22,%20%22path%22:%20%22/%22,%20%22searchQuery%22:%20%22created_at%20%3E=%20'2d'%20OR%20size%20%3C%20'2mb'%20OR%20format='png'%22,%20%22fileType%22:%20%22all%22,%20%22limit%22:%201,%20%22skip%22:%200,%20%22tags%22:%20%22Tag-1,%20Tag-2,%20Tag-3%22%7D"
403+ )
404+ ],
405+ )
406+
407+ resp = self .client .list_files (self .opt )
408+
409+ mock_response_metadata = {
410+ "headers" : {
411+ "Content-Type" : "text/plain" ,
412+ "Accept-Encoding" : "gzip, deflate" ,
413+ "Authorization" : "Basic ZmFrZTEyMjo=" ,
414+ },
415+ "httpStatusCode" : 200 ,
416+ "raw" : [
417+ {
418+ "AITags" : "" ,
419+ "createdAt" : "2022-06-15T08:19:00.843Z" ,
420+ "customCoordinates" : "10,10,20,20" ,
421+ "customMetadata" : {"test100" : 10 },
422+ "embeddedMetadata" : {
423+ "DateCreated" : "2022-06-15T08:19:01.523Z" ,
424+ "DateTimeCreated" : "2022-06-15T08:19:01.524Z" ,
425+ "XResolution" : 250 ,
426+ "YResolution" : 250 ,
427+ },
428+ "fileId" : "62a995f4d875ec08dc587b72" ,
429+ "filePath" : "/sample-cat-image_gr64HPlJS.jpg" ,
430+ "fileType" : "image" ,
431+ "hasAlpha" : False ,
432+ "height" : 354 ,
433+ "isPrivateFile" : False ,
434+ "mime" : "image/jpeg" ,
435+ "name" : "sample-cat-image_gr64HPlJS.jpg" ,
436+ "size" : 23023 ,
437+ "tags" : ["{Tag_1" , " Tag_2" , " Tag_3}" , "tag-to-add-2" ],
438+ "thumbnail" : "https://ik.imagekit.io/your_imagekit_id/tr:n-ik_ml_thumbnail/sample-cat-image_gr64HPlJS.jpg" ,
439+ "type" : "file" ,
440+ "updatedAt" : "2022-06-15T08:19:45.169Z" ,
441+ "url" : "https://ik.imagekit.io/your_imagekit_id/sample-cat-image_gr64HPlJS.jpg" ,
442+ "versionInfo" : {
443+ "id" : "62a995f4d875ec08dc587b72" ,
444+ "name" : "Version " "1" ,
445+ },
446+ "width" : 236 ,
447+ }
448+ ],
449+ }
450+ self .assertEqual (
451+ "http://test.com/v1/files?%7B%22type%22:%20%22file%22,%20%22sort%22:%20%22ASC_CREATED%22,%20%22path%22:%20%22/%22,%20%22searchQuery%22:%20%22created_at%20%3E=%20'2d'%20OR%20size%20%3C%20'2mb'%20OR%20format='png'%22,%20%22fileType%22:%20%22all%22,%20%22limit%22:%201,%20%22skip%22:%200,%20%22tags%22:%20%22Tag-1,%20Tag-2,%20Tag-3%22%7D" ,
452+ responses .calls [0 ].request .url ,
453+ )
454+ self .assertEqual (
455+ camel_dict_to_snake_dict (mock_response_metadata ),
456+ resp .response_metadata .__dict__ ,
457+ )
458+
353459 @responses .activate
354460 def test_list_files_succeeds_with_basic_request (self ) -> None :
355461 """
0 commit comments