Skip to content

Commit 7ed5a44

Browse files
Bump pycloudinary to 1.36.0
1 parent 89e2451 commit 7ed5a44

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cloudinary>=1.35.0
1+
cloudinary>=1.36.0
22
pygments
33
jinja2
44
click

test/helper_test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
RESOURCES_DIR = Path.joinpath(Path(__file__).resolve().parent, "resources")
1616
TEST_FILES_DIR = str(Path.joinpath(RESOURCES_DIR, "test_sync"))
1717

18+
try:
19+
# urllib3 2.x support
20+
# noinspection PyProtectedMember
21+
import urllib3._request_methods
22+
URLLIB3_REQUEST = "urllib3._request_methods.RequestMethods.request"
23+
except ImportError:
24+
URLLIB3_REQUEST = "urllib3.request.RequestMethods.request"
25+
1826
disable_warnings()
1927

2028

@@ -49,7 +57,7 @@ def uploader_response_mock():
4957

5058

5159
def get_request_url(mocker):
52-
return mocker.call_args[0][1]
60+
return mocker.call_args[1]["url"]
5361

5462

5563
def get_params(mocker):
@@ -62,12 +70,12 @@ def get_params(mocker):
6270
In both cases the result would be {"urls": ["http://host1", "http://host2"]}
6371
"""
6472

65-
args = mocker.call_args[0]
66-
if not args or not args[2]:
73+
if not mocker.call_args[1].get("fields"):
6774
return {}
6875
params = {}
6976
reg = re.compile(r'^(.*)\[\d*]$')
70-
fields = args[2].items() if isinstance(args[2], dict) else args[2]
77+
fields = mocker.call_args[1].get("fields")
78+
fields = fields.items() if isinstance(fields, dict) else fields
7179
for k, v in fields:
7280
match = reg.match(k)
7381
if match:

test/test_cli_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from click.testing import CliRunner
77

88
from cloudinary_cli.cli import cli
9-
from test.helper_test import api_response_mock, uploader_response_mock
9+
from test.helper_test import api_response_mock, uploader_response_mock, URLLIB3_REQUEST
1010

1111
API_MOCK_RESPONSE = api_response_mock()
1212
UPLOAD_MOCK_RESPONSE = uploader_response_mock()
@@ -15,23 +15,23 @@
1515
class TestCLIApi(unittest.TestCase):
1616
runner = CliRunner()
1717

18-
@patch('urllib3.request.RequestMethods.request')
18+
@patch(URLLIB3_REQUEST)
1919
def test_admin(self, mocker):
2020
mocker.return_value = API_MOCK_RESPONSE
2121
result = self.runner.invoke(cli, ['ping'])
2222

2323
self.assertEqual(0, result.exit_code, result.output)
2424
self.assertIn('"foo": "bar"', result.output)
2525

26-
@patch('urllib3.request.RequestMethods.request')
26+
@patch(URLLIB3_REQUEST)
2727
def test_upload(self, mocker):
2828
mocker.return_value = UPLOAD_MOCK_RESPONSE
2929
result = self.runner.invoke(cli, ['upload', os.path.abspath(__file__)])
3030

3131
self.assertEqual(0, result.exit_code, result.output)
3232
self.assertIn('"foo": "bar"', result.output)
3333

34-
@patch('urllib3.request.RequestMethods.request')
34+
@patch(URLLIB3_REQUEST)
3535
@unittest.skipUnless(cloudinary.provisioning.account_config().account_id, "requires account_id")
3636
def test_provisioning(self, mocker):
3737
mocker.return_value = API_MOCK_RESPONSE

test/test_cli_search_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from click.testing import CliRunner
55

66
from cloudinary_cli.cli import cli
7-
from test.helper_test import api_response_mock, uploader_response_mock
7+
from test.helper_test import api_response_mock, uploader_response_mock, URLLIB3_REQUEST
88

99
API_MOCK_RESPONSE = api_response_mock()
1010
UPLOAD_MOCK_RESPONSE = uploader_response_mock()
@@ -13,7 +13,7 @@
1313
class TestCLISearchApi(unittest.TestCase):
1414
runner = CliRunner()
1515

16-
@patch('urllib3.request.RequestMethods.request')
16+
@patch(URLLIB3_REQUEST)
1717
def test_search(self, mocker):
1818
mocker.return_value = API_MOCK_RESPONSE
1919
result = self.runner.invoke(cli, ['search', 'cat'])

test/test_modules/test_cli_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from cloudinary_cli.cli import cli
1010
from test.helper_test import unique_suffix, RESOURCES_DIR, TEST_FILES_DIR, delete_cld_folder_if_exists, retry_assertion, \
11-
get_request_url, get_params
11+
get_request_url, get_params, URLLIB3_REQUEST
1212
from test.test_modules.test_cli_upload_dir import UPLOAD_MOCK_RESPONSE
1313

1414

@@ -126,7 +126,7 @@ def _upload_sync_files(self, dir):
126126
self.assertIn("Synced | 12", result.output)
127127
self.assertIn("Done!", result.output)
128128

129-
@patch('urllib3.request.RequestMethods.request')
129+
@patch(URLLIB3_REQUEST)
130130
def test_sync_override_defaults(self, mocker):
131131
mocker.return_value = UPLOAD_MOCK_RESPONSE
132132

test/test_modules/test_cli_upload_dir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from cloudinary_cli.cli import cli
88
from test.helper_test import unique_suffix, TEST_FILES_DIR, delete_cld_folder_if_exists, uploader_response_mock, \
9-
get_request_url, get_params
9+
get_request_url, get_params, URLLIB3_REQUEST
1010

1111
UPLOAD_MOCK_RESPONSE = uploader_response_mock()
1212

@@ -58,7 +58,7 @@ def test_upload_dir_with_exclude_dir_name_option(self):
5858
self.assertIn("as " + self.CLD_UPLOAD_DIR, result.output)
5959
self.assertNotIn("as " + self.CLD_UPLOAD_DIR + "/test_sync/", result.output)
6060

61-
@patch('urllib3.request.RequestMethods.request')
61+
@patch(URLLIB3_REQUEST)
6262
def test_upload_dir_override_defaults(self, mocker):
6363
mocker.return_value = UPLOAD_MOCK_RESPONSE
6464

0 commit comments

Comments
 (0)