cumulusci-plus 5.0.23__py3-none-any.whl → 5.0.25__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cumulusci-plus might be problematic. Click here for more details.
- cumulusci/__about__.py +1 -1
- cumulusci/cli/task.py +17 -0
- cumulusci/cli/tests/test_flow.py +279 -2
- cumulusci/cli/tests/test_task.py +88 -2
- cumulusci/core/flowrunner.py +86 -6
- cumulusci/cumulusci.yml +24 -0
- cumulusci/tasks/create_package_version.py +14 -6
- cumulusci/tasks/salesforce/SfPackageCommands.py +363 -0
- cumulusci/tasks/salesforce/getPackageVersion.py +89 -0
- cumulusci/tasks/salesforce/tests/test_SfPackageCommands.py +554 -0
- cumulusci/tasks/salesforce/tests/test_getPackageVersion.py +651 -0
- cumulusci/tasks/salesforce/tests/test_update_external_credential.py +912 -0
- cumulusci/tasks/salesforce/tests/test_update_named_credential.py +1042 -0
- cumulusci/tasks/salesforce/update_external_credential.py +562 -0
- cumulusci/tasks/salesforce/update_named_credential.py +441 -0
- cumulusci/tasks/salesforce/users/permsets.py +63 -2
- cumulusci/tasks/salesforce/users/tests/test_permsets.py +184 -0
- cumulusci/tasks/sfdmu/__init__.py +0 -0
- cumulusci/tasks/sfdmu/sfdmu.py +256 -0
- cumulusci/tasks/sfdmu/tests/__init__.py +1 -0
- cumulusci/tasks/sfdmu/tests/test_runner.py +212 -0
- cumulusci/tasks/sfdmu/tests/test_sfdmu.py +443 -0
- cumulusci/utils/__init__.py +24 -2
- {cumulusci_plus-5.0.23.dist-info → cumulusci_plus-5.0.25.dist-info}/METADATA +7 -5
- {cumulusci_plus-5.0.23.dist-info → cumulusci_plus-5.0.25.dist-info}/RECORD +29 -16
- {cumulusci_plus-5.0.23.dist-info → cumulusci_plus-5.0.25.dist-info}/WHEEL +0 -0
- {cumulusci_plus-5.0.23.dist-info → cumulusci_plus-5.0.25.dist-info}/entry_points.txt +0 -0
- {cumulusci_plus-5.0.23.dist-info → cumulusci_plus-5.0.25.dist-info}/licenses/AUTHORS.rst +0 -0
- {cumulusci_plus-5.0.23.dist-info → cumulusci_plus-5.0.25.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
from unittest import mock
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from cumulusci.core.exceptions import SalesforceDXException
|
|
6
|
+
from cumulusci.core.versions import PackageType, PackageVersionNumber
|
|
7
|
+
from cumulusci.tasks.salesforce.getPackageVersion import GetPackageVersion
|
|
8
|
+
|
|
9
|
+
from .util import create_task
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestGetPackageVersion:
|
|
13
|
+
"""Test cases for GetPackageVersion task"""
|
|
14
|
+
|
|
15
|
+
def test_init_options_with_string_version(self):
|
|
16
|
+
"""Test _init_options with string version number"""
|
|
17
|
+
task = create_task(
|
|
18
|
+
GetPackageVersion,
|
|
19
|
+
{
|
|
20
|
+
"package_name": "TestPackage",
|
|
21
|
+
"package_version": "1.2.3.4",
|
|
22
|
+
"prefix": "test_",
|
|
23
|
+
"suffix": "_prod",
|
|
24
|
+
"fail_on_error": True,
|
|
25
|
+
},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Verify package_version is parsed correctly
|
|
29
|
+
assert isinstance(task.parsed_options.package_version, PackageVersionNumber)
|
|
30
|
+
assert task.parsed_options.package_version.MajorVersion == 1
|
|
31
|
+
assert task.parsed_options.package_version.MinorVersion == 2
|
|
32
|
+
assert task.parsed_options.package_version.PatchVersion == 3
|
|
33
|
+
assert task.parsed_options.package_version.BuildNumber == 4
|
|
34
|
+
assert (
|
|
35
|
+
task.parsed_options.package_version.package_type == PackageType.SECOND_GEN
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def test_init_options_with_minimal_version(self):
|
|
39
|
+
"""Test _init_options with minimal version number"""
|
|
40
|
+
task = create_task(
|
|
41
|
+
GetPackageVersion,
|
|
42
|
+
{
|
|
43
|
+
"package_name": "TestPackage",
|
|
44
|
+
"package_version": "1.0",
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Verify package_version is parsed correctly with defaults
|
|
49
|
+
assert task.parsed_options.package_version.MajorVersion == 1
|
|
50
|
+
assert task.parsed_options.package_version.MinorVersion == 0
|
|
51
|
+
assert task.parsed_options.package_version.PatchVersion == 0
|
|
52
|
+
assert task.parsed_options.package_version.BuildNumber == 0
|
|
53
|
+
|
|
54
|
+
def test_init_options_with_beta_version(self):
|
|
55
|
+
"""Test _init_options with beta version number"""
|
|
56
|
+
task = create_task(
|
|
57
|
+
GetPackageVersion,
|
|
58
|
+
{
|
|
59
|
+
"package_name": "TestPackage",
|
|
60
|
+
"package_version": "1.2.3 (Beta 5)",
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Verify package_version is parsed correctly
|
|
65
|
+
assert task.parsed_options.package_version.MajorVersion == 1
|
|
66
|
+
assert task.parsed_options.package_version.MinorVersion == 2
|
|
67
|
+
assert task.parsed_options.package_version.PatchVersion == 3
|
|
68
|
+
assert task.parsed_options.package_version.BuildNumber == 5
|
|
69
|
+
|
|
70
|
+
def test_init_options_defaults(self):
|
|
71
|
+
"""Test _init_options with default values"""
|
|
72
|
+
task = create_task(
|
|
73
|
+
GetPackageVersion,
|
|
74
|
+
{
|
|
75
|
+
"package_name": "TestPackage",
|
|
76
|
+
"package_version": "1.0.0.0",
|
|
77
|
+
},
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Verify default values
|
|
81
|
+
assert task.parsed_options.prefix == ""
|
|
82
|
+
assert task.parsed_options.suffix == ""
|
|
83
|
+
assert task.parsed_options.fail_on_error is False
|
|
84
|
+
|
|
85
|
+
@mock.patch(
|
|
86
|
+
"cumulusci.tasks.salesforce.getPackageVersion.get_simple_salesforce_connection"
|
|
87
|
+
)
|
|
88
|
+
@mock.patch("cumulusci.tasks.salesforce.getPackageVersion.get_devhub_config")
|
|
89
|
+
def test_init_task(self, mock_get_devhub_config, mock_get_connection):
|
|
90
|
+
"""Test _init_task method"""
|
|
91
|
+
mock_devhub_config = mock.Mock()
|
|
92
|
+
mock_get_devhub_config.return_value = mock_devhub_config
|
|
93
|
+
mock_tooling = mock.Mock()
|
|
94
|
+
mock_get_connection.return_value = mock_tooling
|
|
95
|
+
|
|
96
|
+
task = create_task(
|
|
97
|
+
GetPackageVersion,
|
|
98
|
+
{
|
|
99
|
+
"package_name": "TestPackage",
|
|
100
|
+
"package_version": "1.0.0.0",
|
|
101
|
+
},
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Mock project config
|
|
105
|
+
task.project_config.project__package__api_version = "58.0"
|
|
106
|
+
|
|
107
|
+
# Call _init_task manually since it's not called automatically
|
|
108
|
+
task._init_task()
|
|
109
|
+
|
|
110
|
+
# Verify tooling connection is created
|
|
111
|
+
mock_get_devhub_config.assert_called_once_with(task.project_config)
|
|
112
|
+
mock_get_connection.assert_called_once_with(
|
|
113
|
+
task.project_config,
|
|
114
|
+
mock_devhub_config,
|
|
115
|
+
api_version="58.0",
|
|
116
|
+
base_url="tooling",
|
|
117
|
+
)
|
|
118
|
+
assert task.tooling == mock_tooling
|
|
119
|
+
|
|
120
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
121
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
122
|
+
def test_run_task_success(self, mock_get_devhub_config, mock_get_connection):
|
|
123
|
+
"""Test _run_task with successful package version found"""
|
|
124
|
+
mock_tooling = mock.Mock()
|
|
125
|
+
mock_get_connection.return_value = mock_tooling
|
|
126
|
+
|
|
127
|
+
# Mock successful query result
|
|
128
|
+
mock_tooling.query.return_value = {
|
|
129
|
+
"size": 1,
|
|
130
|
+
"records": [
|
|
131
|
+
{
|
|
132
|
+
"Id": "05i000000000000",
|
|
133
|
+
"SubscriberPackageVersionId": "04t000000000000",
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
task = create_task(
|
|
139
|
+
GetPackageVersion,
|
|
140
|
+
{
|
|
141
|
+
"package_name": "TestPackage",
|
|
142
|
+
"package_version": "1.2.3.4",
|
|
143
|
+
"prefix": "test_",
|
|
144
|
+
"suffix": "_prod",
|
|
145
|
+
},
|
|
146
|
+
)
|
|
147
|
+
task.tooling = mock_tooling
|
|
148
|
+
|
|
149
|
+
result = task._run_task()
|
|
150
|
+
|
|
151
|
+
# Verify query was called with correct parameters
|
|
152
|
+
expected_query = (
|
|
153
|
+
"SELECT Id, SubscriberPackageVersionId FROM Package2Version WHERE Package2.Name='test_TestPackage_prod' AND "
|
|
154
|
+
"MajorVersion=1 AND "
|
|
155
|
+
"MinorVersion=2 AND "
|
|
156
|
+
"PatchVersion=3 AND "
|
|
157
|
+
"BuildNumber=4"
|
|
158
|
+
)
|
|
159
|
+
mock_tooling.query.assert_called_once_with(expected_query)
|
|
160
|
+
|
|
161
|
+
# Verify return values
|
|
162
|
+
assert result["package_version_id"] == "05i000000000000"
|
|
163
|
+
assert result["subscriber_package_version_id"] == "04t000000000000"
|
|
164
|
+
assert result["package_name"] == "test_TestPackage_prod"
|
|
165
|
+
assert result["package_version"] == task.parsed_options.package_version
|
|
166
|
+
|
|
167
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
168
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
169
|
+
def test_run_task_not_found_without_fail(
|
|
170
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
171
|
+
):
|
|
172
|
+
"""Test _run_task when package version not found without fail_on_error"""
|
|
173
|
+
mock_tooling = mock.Mock()
|
|
174
|
+
mock_get_connection.return_value = mock_tooling
|
|
175
|
+
|
|
176
|
+
# Mock empty query result
|
|
177
|
+
mock_tooling.query.return_value = {"size": 0, "records": []}
|
|
178
|
+
|
|
179
|
+
task = create_task(
|
|
180
|
+
GetPackageVersion,
|
|
181
|
+
{
|
|
182
|
+
"package_name": "TestPackage",
|
|
183
|
+
"package_version": "1.2.3.4",
|
|
184
|
+
"fail_on_error": False,
|
|
185
|
+
},
|
|
186
|
+
)
|
|
187
|
+
task.tooling = mock_tooling
|
|
188
|
+
|
|
189
|
+
# Should not raise exception when fail_on_error=False
|
|
190
|
+
result = task._run_task()
|
|
191
|
+
|
|
192
|
+
# Verify method returns None when no records found
|
|
193
|
+
assert result is None
|
|
194
|
+
|
|
195
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
196
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
197
|
+
def test_run_task_not_found_with_fail(
|
|
198
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
199
|
+
):
|
|
200
|
+
"""Test _run_task when package version not found with fail_on_error=True"""
|
|
201
|
+
mock_tooling = mock.Mock()
|
|
202
|
+
mock_get_connection.return_value = mock_tooling
|
|
203
|
+
|
|
204
|
+
# Mock empty query result
|
|
205
|
+
mock_tooling.query.return_value = {"size": 0, "records": []}
|
|
206
|
+
|
|
207
|
+
task = create_task(
|
|
208
|
+
GetPackageVersion,
|
|
209
|
+
{
|
|
210
|
+
"package_name": "TestPackage",
|
|
211
|
+
"package_version": "1.2.3.4",
|
|
212
|
+
"fail_on_error": True,
|
|
213
|
+
},
|
|
214
|
+
)
|
|
215
|
+
task.tooling = mock_tooling
|
|
216
|
+
|
|
217
|
+
# Should raise SalesforceDXException
|
|
218
|
+
with pytest.raises(SalesforceDXException) as exc_info:
|
|
219
|
+
task._run_task()
|
|
220
|
+
|
|
221
|
+
assert "Package version TestPackage 1.2.3.4 not found" in str(exc_info.value)
|
|
222
|
+
|
|
223
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
224
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
225
|
+
def test_run_task_multiple_versions_without_fail(
|
|
226
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
227
|
+
):
|
|
228
|
+
"""Test _run_task when multiple package versions found without fail_on_error"""
|
|
229
|
+
mock_tooling = mock.Mock()
|
|
230
|
+
mock_get_connection.return_value = mock_tooling
|
|
231
|
+
|
|
232
|
+
# Mock multiple query results
|
|
233
|
+
mock_tooling.query.return_value = {
|
|
234
|
+
"size": 2,
|
|
235
|
+
"records": [
|
|
236
|
+
{
|
|
237
|
+
"Id": "05i000000000001",
|
|
238
|
+
"SubscriberPackageVersionId": "04t000000000001",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"Id": "05i000000000002",
|
|
242
|
+
"SubscriberPackageVersionId": "04t000000000002",
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
task = create_task(
|
|
248
|
+
GetPackageVersion,
|
|
249
|
+
{
|
|
250
|
+
"package_name": "TestPackage",
|
|
251
|
+
"package_version": "1.2.3.4",
|
|
252
|
+
"fail_on_error": False,
|
|
253
|
+
},
|
|
254
|
+
)
|
|
255
|
+
task.tooling = mock_tooling
|
|
256
|
+
|
|
257
|
+
# Should not raise exception, should use first record
|
|
258
|
+
result = task._run_task()
|
|
259
|
+
|
|
260
|
+
# Verify return values use first record
|
|
261
|
+
assert result["package_version_id"] == "05i000000000001"
|
|
262
|
+
assert result["subscriber_package_version_id"] == "04t000000000001"
|
|
263
|
+
|
|
264
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
265
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
266
|
+
def test_run_task_multiple_versions_with_fail(
|
|
267
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
268
|
+
):
|
|
269
|
+
"""Test _run_task when multiple package versions found with fail_on_error=True"""
|
|
270
|
+
mock_tooling = mock.Mock()
|
|
271
|
+
mock_get_connection.return_value = mock_tooling
|
|
272
|
+
|
|
273
|
+
# Mock multiple query results
|
|
274
|
+
mock_tooling.query.return_value = {
|
|
275
|
+
"size": 2,
|
|
276
|
+
"records": [
|
|
277
|
+
{
|
|
278
|
+
"Id": "05i000000000001",
|
|
279
|
+
"SubscriberPackageVersionId": "04t000000000001",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"Id": "05i000000000002",
|
|
283
|
+
"SubscriberPackageVersionId": "04t000000000002",
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
task = create_task(
|
|
289
|
+
GetPackageVersion,
|
|
290
|
+
{
|
|
291
|
+
"package_name": "TestPackage",
|
|
292
|
+
"package_version": "1.2.3.4",
|
|
293
|
+
"fail_on_error": True,
|
|
294
|
+
},
|
|
295
|
+
)
|
|
296
|
+
task.tooling = mock_tooling
|
|
297
|
+
|
|
298
|
+
# Should raise SalesforceDXException
|
|
299
|
+
with pytest.raises(SalesforceDXException) as exc_info:
|
|
300
|
+
task._run_task()
|
|
301
|
+
|
|
302
|
+
assert "Multiple package versions found for TestPackage 1.2.3.4" in str(
|
|
303
|
+
exc_info.value
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
def test_package_name_construction(self):
|
|
307
|
+
"""Test package name construction with prefix and suffix"""
|
|
308
|
+
task = create_task(
|
|
309
|
+
GetPackageVersion,
|
|
310
|
+
{
|
|
311
|
+
"package_name": "TestPackage",
|
|
312
|
+
"package_version": "1.0.0.0",
|
|
313
|
+
"prefix": "pre_",
|
|
314
|
+
"suffix": "_suf",
|
|
315
|
+
},
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
# Test the package name construction logic
|
|
319
|
+
package_name = f"{task.parsed_options.prefix}{task.parsed_options.package_name}{task.parsed_options.suffix}".strip()
|
|
320
|
+
assert package_name == "pre_TestPackage_suf"
|
|
321
|
+
|
|
322
|
+
def test_package_name_construction_with_spaces(self):
|
|
323
|
+
"""Test package name construction with spaces in prefix/suffix"""
|
|
324
|
+
task = create_task(
|
|
325
|
+
GetPackageVersion,
|
|
326
|
+
{
|
|
327
|
+
"package_name": "TestPackage",
|
|
328
|
+
"package_version": "1.0.0.0",
|
|
329
|
+
"prefix": " pre ",
|
|
330
|
+
"suffix": " suf ",
|
|
331
|
+
},
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
# Test the package name construction logic with strip()
|
|
335
|
+
package_name = f"{task.parsed_options.prefix}{task.parsed_options.package_name}{task.parsed_options.suffix}".strip()
|
|
336
|
+
assert package_name == "pre TestPackage suf"
|
|
337
|
+
|
|
338
|
+
def test_package_name_construction_empty_prefix_suffix(self):
|
|
339
|
+
"""Test package name construction with empty prefix and suffix"""
|
|
340
|
+
task = create_task(
|
|
341
|
+
GetPackageVersion,
|
|
342
|
+
{
|
|
343
|
+
"package_name": "TestPackage",
|
|
344
|
+
"package_version": "1.0.0.0",
|
|
345
|
+
"prefix": "",
|
|
346
|
+
"suffix": "",
|
|
347
|
+
},
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
# Test the package name construction logic
|
|
351
|
+
package_name = f"{task.parsed_options.prefix}{task.parsed_options.package_name}{task.parsed_options.suffix}".strip()
|
|
352
|
+
assert package_name == "TestPackage"
|
|
353
|
+
|
|
354
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
355
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
356
|
+
def test_query_construction_with_different_versions(
|
|
357
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
358
|
+
):
|
|
359
|
+
"""Test SOQL query construction with different version numbers"""
|
|
360
|
+
mock_tooling = mock.Mock()
|
|
361
|
+
mock_get_connection.return_value = mock_tooling
|
|
362
|
+
mock_tooling.query.return_value = {
|
|
363
|
+
"size": 1,
|
|
364
|
+
"records": [
|
|
365
|
+
{
|
|
366
|
+
"Id": "05i000000000000",
|
|
367
|
+
"SubscriberPackageVersionId": "04t000000000000",
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
# Test with version 2.5.1.10
|
|
373
|
+
task = create_task(
|
|
374
|
+
GetPackageVersion,
|
|
375
|
+
{
|
|
376
|
+
"package_name": "TestPackage",
|
|
377
|
+
"package_version": "2.5.1.10",
|
|
378
|
+
},
|
|
379
|
+
)
|
|
380
|
+
task.tooling = mock_tooling
|
|
381
|
+
|
|
382
|
+
task._run_task()
|
|
383
|
+
|
|
384
|
+
# Verify query construction
|
|
385
|
+
expected_query = (
|
|
386
|
+
"SELECT Id, SubscriberPackageVersionId FROM Package2Version WHERE Package2.Name='TestPackage' AND "
|
|
387
|
+
"MajorVersion=2 AND "
|
|
388
|
+
"MinorVersion=5 AND "
|
|
389
|
+
"PatchVersion=1 AND "
|
|
390
|
+
"BuildNumber=10"
|
|
391
|
+
)
|
|
392
|
+
mock_tooling.query.assert_called_once_with(expected_query)
|
|
393
|
+
|
|
394
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
395
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
396
|
+
def test_query_construction_with_beta_version(
|
|
397
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
398
|
+
):
|
|
399
|
+
"""Test SOQL query construction with beta version"""
|
|
400
|
+
mock_tooling = mock.Mock()
|
|
401
|
+
mock_get_connection.return_value = mock_tooling
|
|
402
|
+
mock_tooling.query.return_value = {
|
|
403
|
+
"size": 1,
|
|
404
|
+
"records": [
|
|
405
|
+
{
|
|
406
|
+
"Id": "05i000000000000",
|
|
407
|
+
"SubscriberPackageVersionId": "04t000000000000",
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
# Test with beta version
|
|
413
|
+
task = create_task(
|
|
414
|
+
GetPackageVersion,
|
|
415
|
+
{
|
|
416
|
+
"package_name": "TestPackage",
|
|
417
|
+
"package_version": "1.0.0 (Beta 3)",
|
|
418
|
+
},
|
|
419
|
+
)
|
|
420
|
+
task.tooling = mock_tooling
|
|
421
|
+
|
|
422
|
+
task._run_task()
|
|
423
|
+
|
|
424
|
+
# Verify query construction with beta build number
|
|
425
|
+
expected_query = (
|
|
426
|
+
"SELECT Id, SubscriberPackageVersionId FROM Package2Version WHERE Package2.Name='TestPackage' AND "
|
|
427
|
+
"MajorVersion=1 AND "
|
|
428
|
+
"MinorVersion=0 AND "
|
|
429
|
+
"PatchVersion=0 AND "
|
|
430
|
+
"BuildNumber=3"
|
|
431
|
+
)
|
|
432
|
+
mock_tooling.query.assert_called_once_with(expected_query)
|
|
433
|
+
|
|
434
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
435
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
436
|
+
def test_return_values_structure(self, mock_get_devhub_config, mock_get_connection):
|
|
437
|
+
"""Test return values structure and content"""
|
|
438
|
+
mock_tooling = mock.Mock()
|
|
439
|
+
mock_get_connection.return_value = mock_tooling
|
|
440
|
+
mock_tooling.query.return_value = {
|
|
441
|
+
"size": 1,
|
|
442
|
+
"records": [
|
|
443
|
+
{
|
|
444
|
+
"Id": "05i000000000000",
|
|
445
|
+
"SubscriberPackageVersionId": "04t000000000000",
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
task = create_task(
|
|
451
|
+
GetPackageVersion,
|
|
452
|
+
{
|
|
453
|
+
"package_name": "TestPackage",
|
|
454
|
+
"package_version": "1.2.3.4",
|
|
455
|
+
"prefix": "test_",
|
|
456
|
+
"suffix": "_prod",
|
|
457
|
+
},
|
|
458
|
+
)
|
|
459
|
+
task.tooling = mock_tooling
|
|
460
|
+
|
|
461
|
+
result = task._run_task()
|
|
462
|
+
|
|
463
|
+
# Verify all expected return values are present
|
|
464
|
+
expected_keys = [
|
|
465
|
+
"package_version_id",
|
|
466
|
+
"subscriber_package_version_id",
|
|
467
|
+
"package_name",
|
|
468
|
+
"package_version",
|
|
469
|
+
]
|
|
470
|
+
for key in expected_keys:
|
|
471
|
+
assert key in result
|
|
472
|
+
|
|
473
|
+
# Verify return values content
|
|
474
|
+
assert result["package_version_id"] == "05i000000000000"
|
|
475
|
+
assert result["subscriber_package_version_id"] == "04t000000000000"
|
|
476
|
+
assert result["package_name"] == "test_TestPackage_prod"
|
|
477
|
+
assert isinstance(result["package_version"], PackageVersionNumber)
|
|
478
|
+
assert result["package_version"].MajorVersion == 1
|
|
479
|
+
assert result["package_version"].MinorVersion == 2
|
|
480
|
+
assert result["package_version"].PatchVersion == 3
|
|
481
|
+
assert result["package_version"].BuildNumber == 4
|
|
482
|
+
|
|
483
|
+
def test_options_field_descriptions(self):
|
|
484
|
+
"""Test that all options have proper descriptions"""
|
|
485
|
+
task = create_task(
|
|
486
|
+
GetPackageVersion,
|
|
487
|
+
{
|
|
488
|
+
"package_name": "TestPackage",
|
|
489
|
+
"package_version": "1.0.0.0",
|
|
490
|
+
},
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
# Verify required fields
|
|
494
|
+
assert hasattr(task.parsed_options, "package_name")
|
|
495
|
+
assert hasattr(task.parsed_options, "package_version")
|
|
496
|
+
|
|
497
|
+
# Verify optional fields with defaults
|
|
498
|
+
assert hasattr(task.parsed_options, "prefix")
|
|
499
|
+
assert hasattr(task.parsed_options, "suffix")
|
|
500
|
+
assert hasattr(task.parsed_options, "fail_on_error")
|
|
501
|
+
|
|
502
|
+
# Verify default values
|
|
503
|
+
assert task.parsed_options.prefix == ""
|
|
504
|
+
assert task.parsed_options.suffix == ""
|
|
505
|
+
assert task.parsed_options.fail_on_error is False
|
|
506
|
+
|
|
507
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
508
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
509
|
+
def test_logging_messages(self, mock_get_devhub_config, mock_get_connection):
|
|
510
|
+
"""Test logging messages for successful scenario"""
|
|
511
|
+
mock_tooling = mock.Mock()
|
|
512
|
+
mock_get_connection.return_value = mock_tooling
|
|
513
|
+
mock_tooling.query.return_value = {
|
|
514
|
+
"size": 1,
|
|
515
|
+
"records": [
|
|
516
|
+
{
|
|
517
|
+
"Id": "05i000000000000",
|
|
518
|
+
"SubscriberPackageVersionId": "04t000000000000",
|
|
519
|
+
}
|
|
520
|
+
],
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
task = create_task(
|
|
524
|
+
GetPackageVersion,
|
|
525
|
+
{
|
|
526
|
+
"package_name": "TestPackage",
|
|
527
|
+
"package_version": "1.2.3.4",
|
|
528
|
+
},
|
|
529
|
+
)
|
|
530
|
+
task.tooling = mock_tooling
|
|
531
|
+
|
|
532
|
+
# Mock logger to capture log messages
|
|
533
|
+
with mock.patch.object(task.logger, "info") as mock_info, mock.patch.object(
|
|
534
|
+
task.logger, "warning"
|
|
535
|
+
):
|
|
536
|
+
|
|
537
|
+
task._run_task()
|
|
538
|
+
|
|
539
|
+
# Verify info messages were logged
|
|
540
|
+
assert mock_info.call_count >= 3 # At least 3 info messages
|
|
541
|
+
mock_info.assert_any_call("Package version TestPackage 1.2.3.4 found")
|
|
542
|
+
mock_info.assert_any_call("Package version id: 05i000000000000")
|
|
543
|
+
mock_info.assert_any_call("SubscriberPackageVersion Id: 04t000000000000")
|
|
544
|
+
|
|
545
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
546
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
547
|
+
def test_logging_warning_not_found(
|
|
548
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
549
|
+
):
|
|
550
|
+
"""Test logging warning when package version not found"""
|
|
551
|
+
mock_tooling = mock.Mock()
|
|
552
|
+
mock_get_connection.return_value = mock_tooling
|
|
553
|
+
mock_tooling.query.return_value = {"size": 0, "records": []}
|
|
554
|
+
|
|
555
|
+
task = create_task(
|
|
556
|
+
GetPackageVersion,
|
|
557
|
+
{
|
|
558
|
+
"package_name": "TestPackage",
|
|
559
|
+
"package_version": "1.2.3.4",
|
|
560
|
+
"fail_on_error": False,
|
|
561
|
+
},
|
|
562
|
+
)
|
|
563
|
+
task.tooling = mock_tooling
|
|
564
|
+
|
|
565
|
+
# Mock logger to capture log messages
|
|
566
|
+
with mock.patch.object(task.logger, "warning") as mock_warning:
|
|
567
|
+
task._run_task()
|
|
568
|
+
|
|
569
|
+
# Verify warning message was logged
|
|
570
|
+
mock_warning.assert_called_once_with(
|
|
571
|
+
"Package version TestPackage 1.2.3.4 not found"
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
@mock.patch("cumulusci.salesforce_api.utils.get_simple_salesforce_connection")
|
|
575
|
+
@mock.patch("cumulusci.core.config.util.get_devhub_config")
|
|
576
|
+
def test_logging_warning_multiple_found(
|
|
577
|
+
self, mock_get_devhub_config, mock_get_connection
|
|
578
|
+
):
|
|
579
|
+
"""Test logging warning when multiple package versions found"""
|
|
580
|
+
mock_tooling = mock.Mock()
|
|
581
|
+
mock_get_connection.return_value = mock_tooling
|
|
582
|
+
mock_tooling.query.return_value = {
|
|
583
|
+
"size": 2,
|
|
584
|
+
"records": [
|
|
585
|
+
{
|
|
586
|
+
"Id": "05i000000000001",
|
|
587
|
+
"SubscriberPackageVersionId": "04t000000000001",
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"Id": "05i000000000002",
|
|
591
|
+
"SubscriberPackageVersionId": "04t000000000002",
|
|
592
|
+
},
|
|
593
|
+
],
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
task = create_task(
|
|
597
|
+
GetPackageVersion,
|
|
598
|
+
{
|
|
599
|
+
"package_name": "TestPackage",
|
|
600
|
+
"package_version": "1.2.3.4",
|
|
601
|
+
"fail_on_error": False,
|
|
602
|
+
},
|
|
603
|
+
)
|
|
604
|
+
task.tooling = mock_tooling
|
|
605
|
+
|
|
606
|
+
# Mock logger to capture log messages
|
|
607
|
+
with mock.patch.object(task.logger, "warning") as mock_warning:
|
|
608
|
+
task._run_task()
|
|
609
|
+
|
|
610
|
+
# Verify warning message was logged
|
|
611
|
+
mock_warning.assert_called_once_with(
|
|
612
|
+
"Multiple package versions found for TestPackage 1.2.3.4"
|
|
613
|
+
)
|
|
614
|
+
|
|
615
|
+
def test_invalid_version_format(self):
|
|
616
|
+
"""Test handling of invalid version format"""
|
|
617
|
+
with pytest.raises(ValueError):
|
|
618
|
+
create_task(
|
|
619
|
+
GetPackageVersion,
|
|
620
|
+
{
|
|
621
|
+
"package_name": "TestPackage",
|
|
622
|
+
"package_version": "invalid_version",
|
|
623
|
+
},
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
def test_empty_package_name(self):
|
|
627
|
+
"""Test with empty package name"""
|
|
628
|
+
task = create_task(
|
|
629
|
+
GetPackageVersion,
|
|
630
|
+
{
|
|
631
|
+
"package_name": "",
|
|
632
|
+
"package_version": "1.0.0.0",
|
|
633
|
+
},
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
# Should not raise exception during initialization
|
|
637
|
+
assert task.parsed_options.package_name == ""
|
|
638
|
+
|
|
639
|
+
def test_very_long_package_name(self):
|
|
640
|
+
"""Test with very long package name"""
|
|
641
|
+
long_name = "A" * 1000
|
|
642
|
+
task = create_task(
|
|
643
|
+
GetPackageVersion,
|
|
644
|
+
{
|
|
645
|
+
"package_name": long_name,
|
|
646
|
+
"package_version": "1.0.0.0",
|
|
647
|
+
},
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
# Should not raise exception during initialization
|
|
651
|
+
assert task.parsed_options.package_name == long_name
|