Skip to content

Commit 14c9229

Browse files
Add support for on_success upload parameter
1 parent cae4ff1 commit 14c9229

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

cloudinary/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"eager_notification_url",
9393
"eager_async",
9494
"eval",
95+
"on_success",
9596
"proxy",
9697
"folder",
9798
"asset_folder",

test/helper_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
EVAL_STR = 'if (resource_info["width"] < 450) { upload_options["quality_analysis"] = true }; ' \
4242
'upload_options["context"] = "width=" + resource_info["width"]'
4343

44+
ON_SUCCESS_STR = 'current_asset.update({tags: ["autocaption"]});'
4445

4546
class UTC(tzinfo):
4647
"""UTC"""

test/test_uploader.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from test.cache.storage.dummy_cache_storage import DummyCacheStorage
1919
from test.helper_test import uploader_response_mock, SUFFIX, TEST_IMAGE, get_params, get_headers, TEST_ICON, TEST_DOC, \
2020
REMOTE_TEST_IMAGE, UTC, populate_large_file, TEST_UNICODE_IMAGE, get_uri, get_method, get_param, \
21-
cleanup_test_resources_by_tag, cleanup_test_transformation, cleanup_test_resources, EVAL_STR
21+
cleanup_test_resources_by_tag, cleanup_test_transformation, cleanup_test_resources, EVAL_STR, ON_SUCCESS_STR
2222
from test.test_utils import TEST_ID, TEST_FOLDER
2323

2424
MOCK_RESPONSE = uploader_response_mock()
@@ -427,13 +427,6 @@ def test_use_filename(self):
427427

428428
@unittest.skipUnless(cloudinary.config().api_secret, "requires api_key/api_secret")
429429
def test_explicit(self):
430-
"""Should support explicit """
431-
result = uploader.explicit("cloudinary", type="twitter_name", eager=[TEST_TRANS_SCALE2_PNG], tags=[UNIQUE_TAG])
432-
params = dict(TEST_TRANS_SCALE2_PNG, type="twitter_name", version=result["version"])
433-
url = utils.cloudinary_url("cloudinary", **params)[0]
434-
actual = result["eager"][0]["url"]
435-
self.assertEqual(parse_url(actual).path, parse_url(url).path)
436-
437430
# Test explicit with metadata
438431
resource = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG])
439432
result_metadata = uploader.explicit(resource['public_id'], type="upload", metadata=METADATA_FIELDS,
@@ -958,6 +951,7 @@ def test_various_upload_parameters(self, request_mock):
958951
'accessibility_analysis': True,
959952
'media_metadata': True,
960953
'visual_search': True,
954+
'on_success': ON_SUCCESS_STR
961955
}
962956

963957
uploader.upload(TEST_IMAGE, **options)
@@ -972,7 +966,6 @@ def test_various_upload_parameters(self, request_mock):
972966
for param in options.keys():
973967
self.assertIn(param, params)
974968

975-
976969
@unittest.skipUnless(cloudinary.config().api_secret, "requires api_key/api_secret")
977970
def test_eval_upload_parameter(self):
978971
"""Should support eval in upload"""

0 commit comments

Comments
 (0)