@@ -12,14 +12,13 @@ def setUp(self):
1212 self .mock_search_result = {
1313 'resources' : [
1414 {
15- 'public_id' : 'test_asset ' ,
15+ 'public_id' : 'sample ' ,
1616 'type' : 'upload' ,
1717 'resource_type' : 'image' ,
1818 'format' : 'jpg' ,
19- 'secure_url' : 'https://res.cloudinary.com/test /image/upload/test_asset .jpg' ,
19+ 'secure_url' : 'https://res.cloudinary.com/demo /image/upload/v1234567890/sample .jpg' ,
2020 'tags' : ['tag1' , 'tag2' ],
2121 'context' : {'key' : 'value' },
22- 'access_control' : None ,
2322 'folder' : 'test_folder' ,
2423 'display_name' : 'Test Asset'
2524 }
@@ -97,7 +96,7 @@ def test_search_assets_with_mixed_types(self, mock_logger):
9796 error_call = mock_logger .error .call_args [0 ][0 ]
9897 self .assertIn ("facebook" , error_call )
9998 # Verify that only the disallowed type is mentioned in the error part
100- self .assertIn ("Unsupported type(s) in search expression: facebook" , error_call )
99+ self .assertIn ("Unsupported type(s) in search expression: type: facebook" , error_call )
101100 self .assertEqual (result , False )
102101
103102 def test_search_assets_type_validation_regex (self ):
@@ -123,21 +122,20 @@ def test_search_assets_type_validation_regex(self):
123122 def test_process_metadata_basic (self ):
124123 """Test process_metadata with basic asset"""
125124 res = {
126- 'public_id' : 'test_asset ' ,
125+ 'public_id' : 'sample ' ,
127126 'type' : 'upload' ,
128127 'resource_type' : 'image' ,
129128 'format' : 'jpg' ,
130- 'secure_url' : 'https://res.cloudinary.com/test/image/upload/test_asset.jpg' ,
131- 'access_control' : None
129+ 'secure_url' : 'https://res.cloudinary.com/demo/image/upload/v1234567890/sample.jpg'
132130 }
133131
134132 options , url = process_metadata (
135133 res , overwrite = True , async_ = False , notification_url = None ,
136134 auth_token = None , ttl = 3600 , copy_fields = []
137135 )
138136
139- self .assertEqual (url , 'https://res.cloudinary.com/test /image/upload/test_asset .jpg' )
140- self .assertEqual (options ['public_id' ], 'test_asset ' )
137+ self .assertEqual (url , 'https://res.cloudinary.com/demo /image/upload/v1234567890/sample .jpg' )
138+ self .assertEqual (options ['public_id' ], 'sample ' )
141139 self .assertEqual (options ['type' ], 'upload' )
142140 self .assertEqual (options ['resource_type' ], 'image' )
143141 self .assertEqual (options ['overwrite' ], True )
@@ -146,12 +144,11 @@ def test_process_metadata_basic(self):
146144 def test_process_metadata_with_tags_and_context (self ):
147145 """Test process_metadata copying tags and context"""
148146 res = {
149- 'public_id' : 'test_asset ' ,
147+ 'public_id' : 'sample ' ,
150148 'type' : 'upload' ,
151149 'resource_type' : 'image' ,
152150 'format' : 'jpg' ,
153- 'secure_url' : 'https://res.cloudinary.com/test/image/upload/test_asset.jpg' ,
154- 'access_control' : None ,
151+ 'secure_url' : 'https://res.cloudinary.com/demo/image/upload/v1234567890/sample.jpg' ,
155152 'tags' : ['tag1' , 'tag2' ],
156153 'context' : {'key' : 'value' }
157154 }
@@ -170,12 +167,11 @@ def test_process_metadata_with_tags_and_context(self):
170167 def test_process_metadata_with_folder (self ):
171168 """Test process_metadata with folder handling"""
172169 res = {
173- 'public_id' : 'test_asset ' ,
170+ 'public_id' : 'sample ' ,
174171 'type' : 'upload' ,
175172 'resource_type' : 'image' ,
176173 'format' : 'jpg' ,
177- 'secure_url' : 'https://res.cloudinary.com/test/image/upload/test_asset.jpg' ,
178- 'access_control' : None ,
174+ 'secure_url' : 'https://res.cloudinary.com/demo/image/upload/v1234567890/sample.jpg' ,
179175 'folder' : 'test_folder'
180176 }
181177
@@ -189,12 +185,11 @@ def test_process_metadata_with_folder(self):
189185 def test_process_metadata_with_asset_folder (self ):
190186 """Test process_metadata with asset_folder"""
191187 res = {
192- 'public_id' : 'test_asset ' ,
188+ 'public_id' : 'sample ' ,
193189 'type' : 'upload' ,
194190 'resource_type' : 'image' ,
195191 'format' : 'jpg' ,
196- 'secure_url' : 'https://res.cloudinary.com/test/image/upload/test_asset.jpg' ,
197- 'access_control' : None ,
192+ 'secure_url' : 'https://res.cloudinary.com/demo/image/upload/v1234567890/sample.jpg' ,
198193 'asset_folder' : 'asset_folder_test'
199194 }
200195
@@ -208,12 +203,11 @@ def test_process_metadata_with_asset_folder(self):
208203 def test_process_metadata_with_display_name (self ):
209204 """Test process_metadata with display_name"""
210205 res = {
211- 'public_id' : 'test_asset ' ,
206+ 'public_id' : 'sample ' ,
212207 'type' : 'upload' ,
213208 'resource_type' : 'image' ,
214209 'format' : 'jpg' ,
215- 'secure_url' : 'https://res.cloudinary.com/test/image/upload/test_asset.jpg' ,
216- 'access_control' : None ,
210+ 'secure_url' : 'https://res.cloudinary.com/demo/image/upload/v1234567890/sample.jpg' ,
217211 'display_name' : 'Test Asset Display Name'
218212 }
219213
@@ -229,14 +223,14 @@ def test_process_metadata_with_display_name(self):
229223 def test_process_metadata_restricted_asset_no_auth_token (self , mock_private_url , mock_time ):
230224 """Test process_metadata with restricted asset and no auth token"""
231225 mock_time .return_value = 1000
232- mock_private_url .return_value = 'https://private.url/test_asset. jpg'
226+ mock_private_url .return_value = 'https://api.cloudinary.com/v1_1/demo/image/download?api_key=123456789012345&format= jpg&public_id=sample&signature=abcdef123456789×tamp=1234567890 '
233227
234228 res = {
235- 'public_id' : 'test_asset ' ,
229+ 'public_id' : 'sample ' ,
236230 'type' : 'upload' ,
237231 'resource_type' : 'image' ,
238232 'format' : 'jpg' ,
239- 'secure_url' : 'https://res.cloudinary.com/test /image/upload/test_asset .jpg' ,
233+ 'secure_url' : 'https://res.cloudinary.com/demo /image/upload/v1234567890/sample .jpg' ,
240234 'access_control' : [{'access_type' : 'token' }]
241235 }
242236
@@ -247,21 +241,21 @@ def test_process_metadata_restricted_asset_no_auth_token(self, mock_private_url,
247241
248242 # Should use private download URL
249243 mock_private_url .assert_called_once_with (
250- 'test_asset ' , 'jpg' , resource_type = 'image' , type = 'upload' , expires_at = 4600
244+ 'sample ' , 'jpg' , resource_type = 'image' , type = 'upload' , expires_at = 4600
251245 )
252- self .assertEqual (url , 'https://private.url/test_asset. jpg' )
246+ self .assertEqual (url , 'https://api.cloudinary.com/v1_1/demo/image/download?api_key=123456789012345&format= jpg&public_id=sample&signature=abcdef123456789×tamp=1234567890 ' )
253247
254248 @patch ('cloudinary.utils.cloudinary_url' )
255249 def test_process_metadata_restricted_asset_with_auth_token (self , mock_cloudinary_url ):
256250 """Test process_metadata with restricted asset and auth token"""
257- mock_cloudinary_url .return_value = ('https://signed.url/test_asset .jpg' , {})
251+ mock_cloudinary_url .return_value = ('https://res.cloudinary.com/demo/image/upload/s--AbCdEfGhI--/sample .jpg' , {})
258252
259253 res = {
260- 'public_id' : 'test_asset ' ,
254+ 'public_id' : 'sample ' ,
261255 'type' : 'upload' ,
262256 'resource_type' : 'image' ,
263257 'format' : 'jpg' ,
264- 'secure_url' : 'https://res.cloudinary.com/test /image/upload/test_asset .jpg' ,
258+ 'secure_url' : 'https://res.cloudinary.com/demo /image/upload/v1234567890/sample .jpg' ,
265259 'access_control' : [{'access_type' : 'token' }]
266260 }
267261
@@ -272,27 +266,27 @@ def test_process_metadata_restricted_asset_with_auth_token(self, mock_cloudinary
272266
273267 # Should use signed URL
274268 mock_cloudinary_url .assert_called_once_with (
275- 'test_asset .jpg' ,
269+ 'sample .jpg' ,
276270 type = 'upload' ,
277271 resource_type = 'image' ,
278272 auth_token = {'duration' : 3600 },
279273 secure = True ,
280274 sign_url = True
281275 )
282276 # The current implementation assigns the tuple directly, so we expect the tuple
283- self .assertEqual (url , ('https://signed.url/test_asset .jpg' , {}))
277+ self .assertEqual (url , ('https://res.cloudinary.com/demo/image/upload/s--AbCdEfGhI--/sample .jpg' , {}))
284278
285279 @patch ('cloudinary.utils.cloudinary_url' )
286280 def test_process_metadata_restricted_raw_asset_with_auth_token (self , mock_cloudinary_url ):
287281 """Test process_metadata with restricted raw asset and auth token"""
288- mock_cloudinary_url .return_value = ('https://signed.url/test_asset ' , {})
282+ mock_cloudinary_url .return_value = ('https://res.cloudinary.com/demo/raw/upload/s--XyZaBcDeF--/sample_document ' , {})
289283
290284 res = {
291- 'public_id' : 'test_asset ' ,
285+ 'public_id' : 'sample_document ' ,
292286 'type' : 'upload' ,
293287 'resource_type' : 'raw' ,
294288 'format' : 'pdf' ,
295- 'secure_url' : 'https://res.cloudinary.com/test /raw/upload/test_asset .pdf' ,
289+ 'secure_url' : 'https://res.cloudinary.com/demo /raw/upload/v1234567890/sample_document .pdf' ,
296290 'access_control' : [{'access_type' : 'token' }]
297291 }
298292
@@ -303,15 +297,15 @@ def test_process_metadata_restricted_raw_asset_with_auth_token(self, mock_cloudi
303297
304298 # For raw assets, should not append format to public_id
305299 mock_cloudinary_url .assert_called_once_with (
306- 'test_asset ' , # No .pdf extension for raw assets
300+ 'sample_document ' , # No .pdf extension for raw assets
307301 type = 'upload' ,
308302 resource_type = 'raw' ,
309303 auth_token = {'duration' : 3600 },
310304 secure = True ,
311305 sign_url = True
312306 )
313307 # The current implementation assigns the tuple directly, so we expect the tuple
314- self .assertEqual (url , ('https://signed.url/test_asset ' , {}))
308+ self .assertEqual (url , ('https://res.cloudinary.com/demo/raw/upload/s--XyZaBcDeF--/sample_document ' , {}))
315309
316310
317311if __name__ == '__main__' :
0 commit comments