Skip to content

Commit

Permalink
Add support for on_success upload parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary authored Aug 13, 2023
1 parent cae4ff1 commit 14c9229
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions cloudinary/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"eager_notification_url",
"eager_async",
"eval",
"on_success",
"proxy",
"folder",
"asset_folder",
Expand Down
1 change: 1 addition & 0 deletions test/helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
EVAL_STR = 'if (resource_info["width"] < 450) { upload_options["quality_analysis"] = true }; ' \
'upload_options["context"] = "width=" + resource_info["width"]'

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

class UTC(tzinfo):
"""UTC"""
Expand Down
11 changes: 2 additions & 9 deletions test/test_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from test.cache.storage.dummy_cache_storage import DummyCacheStorage
from test.helper_test import uploader_response_mock, SUFFIX, TEST_IMAGE, get_params, get_headers, TEST_ICON, TEST_DOC, \
REMOTE_TEST_IMAGE, UTC, populate_large_file, TEST_UNICODE_IMAGE, get_uri, get_method, get_param, \
cleanup_test_resources_by_tag, cleanup_test_transformation, cleanup_test_resources, EVAL_STR
cleanup_test_resources_by_tag, cleanup_test_transformation, cleanup_test_resources, EVAL_STR, ON_SUCCESS_STR
from test.test_utils import TEST_ID, TEST_FOLDER

MOCK_RESPONSE = uploader_response_mock()
Expand Down Expand Up @@ -427,13 +427,6 @@ def test_use_filename(self):

@unittest.skipUnless(cloudinary.config().api_secret, "requires api_key/api_secret")
def test_explicit(self):
"""Should support explicit """
result = uploader.explicit("cloudinary", type="twitter_name", eager=[TEST_TRANS_SCALE2_PNG], tags=[UNIQUE_TAG])
params = dict(TEST_TRANS_SCALE2_PNG, type="twitter_name", version=result["version"])
url = utils.cloudinary_url("cloudinary", **params)[0]
actual = result["eager"][0]["url"]
self.assertEqual(parse_url(actual).path, parse_url(url).path)

# Test explicit with metadata
resource = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG])
result_metadata = uploader.explicit(resource['public_id'], type="upload", metadata=METADATA_FIELDS,
Expand Down Expand Up @@ -958,6 +951,7 @@ def test_various_upload_parameters(self, request_mock):
'accessibility_analysis': True,
'media_metadata': True,
'visual_search': True,
'on_success': ON_SUCCESS_STR
}

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


@unittest.skipUnless(cloudinary.config().api_secret, "requires api_key/api_secret")
def test_eval_upload_parameter(self):
"""Should support eval in upload"""
Expand Down

0 comments on commit 14c9229

Please sign in to comment.