Skip to content

Commit 17981a8

Browse files
tentatively add user input mock - 3
1 parent b074d0e commit 17981a8

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/test_modules/test_cli_clone.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_create_metadata_item_rule(self, mock_add_metadata_rule):
115115

116116
@patch.object(clone_metadata_utils, 'create_metadata_items')
117117
@patch.object(clone_metadata_utils, 'list_metadata_items')
118-
@patch('cloudinary_cli.utils.utils.confirm_action')
118+
@patch('builtins.input', return_value='true')
119119
def test_compare_create_metadata_items_new_fields(self,mock_confirm, mock_list, mock_create, ):
120120
"""Test comparing and creating new metadata fields"""
121121
metadata_fields = {
@@ -132,15 +132,15 @@ def test_compare_create_metadata_items_new_fields(self,mock_confirm, mock_list,
132132
}
133133
]
134134
}
135-
mock_confirm.return_value = True
135+
136136
mock_source_fields = metadata_fields
137137
mock_list.return_value = metadata_fields
138138
mock_destination_fields = {
139139
'metadata_fields': []
140140
}
141141

142142
clone_metadata_utils.compare_create_metadata_items(mock_source_fields, mock_destination_fields, key="metadata_fields", **self.mock_target_config)
143-
mock_confirm.return_value = True
143+
144144
# Both fields should be created
145145
self.assertEqual(mock_create.call_count, 2)
146146
mock_create.assert_any_call('add_metadata_field', mock_source_fields['metadata_fields'][0], **self.mock_target_config)
@@ -152,7 +152,7 @@ def test_compare_create_metadata_items_new_fields(self,mock_confirm, mock_list,
152152

153153
@patch.object(clone_metadata_utils, 'create_metadata_items')
154154
@patch.object(clone_metadata_utils, 'list_metadata_items')
155-
@patch('cloudinary_cli.utils.utils.confirm_action')
155+
@patch('builtins.input', return_value='true')
156156
def test_compare_create_metadata_items_new_rules(self, mock_list, mock_create, mock_confirm):
157157
"""Test comparing and creating new metadata rules"""
158158
metadata_rules = {
@@ -177,7 +177,7 @@ def test_compare_create_metadata_items_new_rules(self, mock_list, mock_create, m
177177
}
178178
]
179179
}
180-
mock_confirm.return_value = True
180+
181181
mock_source_metadata_rules = metadata_rules
182182
mock_list.return_value = metadata_rules
183183

@@ -196,7 +196,7 @@ def test_compare_create_metadata_items_new_rules(self, mock_list, mock_create, m
196196
self.assertEqual(result, mock_list.return_value)
197197

198198
@patch.object(clone_metadata_utils, 'create_metadata_items')
199-
@patch('cloudinary_cli.utils.utils.confirm_action')
199+
@patch('builtins.input', return_value='true')
200200
def test_compare_create_metadata_items_existing_fields(self, mock_create, mock_confirm):
201201
"""Test comparing when fields already exist"""
202202
mock_source_fields = {
@@ -219,14 +219,14 @@ def test_compare_create_metadata_items_existing_fields(self, mock_create, mock_c
219219
}
220220
]
221221
}
222-
mock_confirm.return_value = True
222+
223223
clone_metadata_utils.compare_create_metadata_items(mock_source_fields, mock_destination_fields, key="metadata_fields", **self.mock_target_config)
224224

225225
# No fields should be created
226226
mock_create.assert_not_called()
227227

228228
@patch.object(clone_metadata_utils, 'create_metadata_items')
229-
@patch('cloudinary_cli.utils.utils.confirm_action')
229+
@patch('builtins.input', return_value='true')
230230
def test_compare_create_metadata_items_existing_rules(self, mock_create, mock_confirm):
231231
"""Test comparing when rules already exist"""
232232

@@ -258,15 +258,15 @@ def test_compare_create_metadata_items_existing_rules(self, mock_create, mock_co
258258
}
259259
]
260260
}
261-
mock_confirm.return_value = True
261+
262262
clone_metadata_utils.compare_create_metadata_items(mock_source_metadata_rules, mock_destination_metadata_rules, key="metadata_rules", **self.mock_target_config)
263263

264264
# No rules should be created
265265
mock_create.assert_not_called()
266266

267267
@patch.object(clone_metadata_utils, 'create_metadata_items')
268268
@patch.object(clone_metadata_utils, 'list_metadata_items')
269-
@patch('cloudinary_cli.utils.utils.confirm_action')
269+
@patch('builtins.input', return_value='true')
270270
def test_compare_create_metadata_items_mixed_scenario(self, mock_list, mock_create, mock_confirm):
271271
"""Test comparing with mix of new and existing fields"""
272272
metadata_fields = {
@@ -294,7 +294,7 @@ def test_compare_create_metadata_items_mixed_scenario(self, mock_list, mock_crea
294294
}
295295
]
296296
}
297-
mock_confirm.return_value = True
297+
298298
mock_source_fields= metadata_fields
299299
mock_list.return_value = metadata_fields
300300

@@ -309,7 +309,7 @@ def test_compare_create_metadata_items_mixed_scenario(self, mock_list, mock_crea
309309

310310
@patch.object(clone_metadata_utils, 'create_metadata_items')
311311
@patch.object(clone_metadata_utils, 'list_metadata_items')
312-
@patch('cloudinary_cli.utils.utils.confirm_action')
312+
@patch('builtins.input', return_value='true')
313313
def test_compare_create_metadata_items_mixed_rules_scenario(self, mock_list, mock_create, mock_confirm):
314314
"""Test comparing with mix of new and existing rules"""
315315
metadata_rules = {
@@ -349,7 +349,7 @@ def test_compare_create_metadata_items_mixed_rules_scenario(self, mock_list, moc
349349
}
350350
]
351351
}
352-
mock_confirm.return_value = True
352+
353353
mock_source_metadata_rules = metadata_rules
354354
mock_list.return_value = metadata_rules
355355

0 commit comments

Comments
 (0)