cumulusci-plus 5.0.0__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.

Files changed (744) hide show
  1. cumulusci/__about__.py +1 -0
  2. cumulusci/__init__.py +22 -0
  3. cumulusci/__main__.py +3 -0
  4. cumulusci/cli/__init__.py +0 -0
  5. cumulusci/cli/cci.py +244 -0
  6. cumulusci/cli/error.py +125 -0
  7. cumulusci/cli/flow.py +185 -0
  8. cumulusci/cli/logger.py +72 -0
  9. cumulusci/cli/org.py +692 -0
  10. cumulusci/cli/plan.py +181 -0
  11. cumulusci/cli/project.py +391 -0
  12. cumulusci/cli/robot.py +116 -0
  13. cumulusci/cli/runtime.py +190 -0
  14. cumulusci/cli/service.py +521 -0
  15. cumulusci/cli/task.py +295 -0
  16. cumulusci/cli/tests/__init__.py +0 -0
  17. cumulusci/cli/tests/test_cci.py +545 -0
  18. cumulusci/cli/tests/test_error.py +170 -0
  19. cumulusci/cli/tests/test_flow.py +276 -0
  20. cumulusci/cli/tests/test_logger.py +25 -0
  21. cumulusci/cli/tests/test_org.py +1438 -0
  22. cumulusci/cli/tests/test_plan.py +245 -0
  23. cumulusci/cli/tests/test_project.py +235 -0
  24. cumulusci/cli/tests/test_robot.py +177 -0
  25. cumulusci/cli/tests/test_runtime.py +197 -0
  26. cumulusci/cli/tests/test_service.py +853 -0
  27. cumulusci/cli/tests/test_task.py +266 -0
  28. cumulusci/cli/tests/test_ui.py +310 -0
  29. cumulusci/cli/tests/test_utils.py +122 -0
  30. cumulusci/cli/tests/utils.py +52 -0
  31. cumulusci/cli/ui.py +234 -0
  32. cumulusci/cli/utils.py +150 -0
  33. cumulusci/conftest.py +181 -0
  34. cumulusci/core/__init__.py +0 -0
  35. cumulusci/core/config/BaseConfig.py +5 -0
  36. cumulusci/core/config/BaseTaskFlowConfig.py +5 -0
  37. cumulusci/core/config/OrgConfig.py +5 -0
  38. cumulusci/core/config/ScratchOrgConfig.py +5 -0
  39. cumulusci/core/config/__init__.py +125 -0
  40. cumulusci/core/config/base_config.py +111 -0
  41. cumulusci/core/config/base_task_flow_config.py +82 -0
  42. cumulusci/core/config/marketing_cloud_service_config.py +83 -0
  43. cumulusci/core/config/oauth2_service_config.py +17 -0
  44. cumulusci/core/config/org_config.py +604 -0
  45. cumulusci/core/config/project_config.py +782 -0
  46. cumulusci/core/config/scratch_org_config.py +251 -0
  47. cumulusci/core/config/sfdx_org_config.py +220 -0
  48. cumulusci/core/config/tests/_test_config_backwards_compatibility.py +33 -0
  49. cumulusci/core/config/tests/test_config.py +1895 -0
  50. cumulusci/core/config/tests/test_config_expensive.py +839 -0
  51. cumulusci/core/config/tests/test_config_util.py +91 -0
  52. cumulusci/core/config/universal_config.py +88 -0
  53. cumulusci/core/config/util.py +18 -0
  54. cumulusci/core/datasets.py +303 -0
  55. cumulusci/core/debug.py +33 -0
  56. cumulusci/core/dependencies/__init__.py +55 -0
  57. cumulusci/core/dependencies/base.py +561 -0
  58. cumulusci/core/dependencies/dependencies.py +273 -0
  59. cumulusci/core/dependencies/github.py +177 -0
  60. cumulusci/core/dependencies/github_resolvers.py +244 -0
  61. cumulusci/core/dependencies/resolvers.py +580 -0
  62. cumulusci/core/dependencies/tests/__init__.py +0 -0
  63. cumulusci/core/dependencies/tests/conftest.py +385 -0
  64. cumulusci/core/dependencies/tests/test_dependencies.py +950 -0
  65. cumulusci/core/dependencies/tests/test_github.py +83 -0
  66. cumulusci/core/dependencies/tests/test_resolvers.py +1027 -0
  67. cumulusci/core/dependencies/utils.py +13 -0
  68. cumulusci/core/enums.py +11 -0
  69. cumulusci/core/exceptions.py +311 -0
  70. cumulusci/core/flowrunner.py +888 -0
  71. cumulusci/core/github.py +665 -0
  72. cumulusci/core/keychain/__init__.py +24 -0
  73. cumulusci/core/keychain/base_project_keychain.py +441 -0
  74. cumulusci/core/keychain/encrypted_file_project_keychain.py +945 -0
  75. cumulusci/core/keychain/environment_project_keychain.py +7 -0
  76. cumulusci/core/keychain/serialization.py +152 -0
  77. cumulusci/core/keychain/subprocess_keychain.py +24 -0
  78. cumulusci/core/keychain/tests/conftest.py +50 -0
  79. cumulusci/core/keychain/tests/test_base_project_keychain.py +299 -0
  80. cumulusci/core/keychain/tests/test_encrypted_file_project_keychain.py +1228 -0
  81. cumulusci/core/metadeploy/__init__.py +0 -0
  82. cumulusci/core/metadeploy/api.py +88 -0
  83. cumulusci/core/metadeploy/plans.py +25 -0
  84. cumulusci/core/metadeploy/tests/test_api.py +276 -0
  85. cumulusci/core/runtime.py +115 -0
  86. cumulusci/core/sfdx.py +162 -0
  87. cumulusci/core/source/__init__.py +16 -0
  88. cumulusci/core/source/github.py +50 -0
  89. cumulusci/core/source/local_folder.py +35 -0
  90. cumulusci/core/source_transforms/__init__.py +0 -0
  91. cumulusci/core/source_transforms/tests/test_transforms.py +1091 -0
  92. cumulusci/core/source_transforms/transforms.py +532 -0
  93. cumulusci/core/tasks.py +404 -0
  94. cumulusci/core/template_utils.py +59 -0
  95. cumulusci/core/tests/__init__.py +0 -0
  96. cumulusci/core/tests/cassettes/TestDatasetsE2E.test_datasets_e2e.yaml +215 -0
  97. cumulusci/core/tests/cassettes/TestDatasetsE2E.test_datasets_extract_standard_objects.yaml +199 -0
  98. cumulusci/core/tests/cassettes/TestDatasetsE2E.test_datasets_read_explicit_extract_declaration.yaml +3 -0
  99. cumulusci/core/tests/fake_remote_repo/cumulusci.yml +32 -0
  100. cumulusci/core/tests/fake_remote_repo/tasks/directory/example_2.py +6 -0
  101. cumulusci/core/tests/fake_remote_repo/tasks/example.py +43 -0
  102. cumulusci/core/tests/fake_remote_repo_2/cumulusci.yml +11 -0
  103. cumulusci/core/tests/fake_remote_repo_2/tasks/example_3.py +6 -0
  104. cumulusci/core/tests/test_datasets_e2e.py +386 -0
  105. cumulusci/core/tests/test_exceptions.py +11 -0
  106. cumulusci/core/tests/test_flowrunner.py +836 -0
  107. cumulusci/core/tests/test_github.py +942 -0
  108. cumulusci/core/tests/test_sfdx.py +138 -0
  109. cumulusci/core/tests/test_source.py +678 -0
  110. cumulusci/core/tests/test_tasks.py +262 -0
  111. cumulusci/core/tests/test_utils.py +141 -0
  112. cumulusci/core/tests/test_utils_merge_config.py +276 -0
  113. cumulusci/core/tests/test_versions.py +76 -0
  114. cumulusci/core/tests/untrusted_repo_child/cumulusci.yml +7 -0
  115. cumulusci/core/tests/untrusted_repo_child/tasks/untrusted_child.py +6 -0
  116. cumulusci/core/tests/untrusted_repo_parent/cumulusci.yml +26 -0
  117. cumulusci/core/tests/untrusted_repo_parent/tasks/untrusted_parent.py +6 -0
  118. cumulusci/core/tests/utils.py +116 -0
  119. cumulusci/core/tests/yaml/global.yaml +0 -0
  120. cumulusci/core/utils.py +402 -0
  121. cumulusci/core/versions.py +149 -0
  122. cumulusci/cumulusci.yml +1621 -0
  123. cumulusci/files/admin_profile.xml +20 -0
  124. cumulusci/files/delete_excludes.txt +424 -0
  125. cumulusci/files/templates/project/README.md +12 -0
  126. cumulusci/files/templates/project/cumulusci.yml +63 -0
  127. cumulusci/files/templates/project/dot-gitignore +60 -0
  128. cumulusci/files/templates/project/mapping.yml +45 -0
  129. cumulusci/files/templates/project/scratch_def.json +25 -0
  130. cumulusci/oauth/__init__.py +0 -0
  131. cumulusci/oauth/client.py +400 -0
  132. cumulusci/oauth/exceptions.py +9 -0
  133. cumulusci/oauth/salesforce.py +95 -0
  134. cumulusci/oauth/tests/__init__.py +0 -0
  135. cumulusci/oauth/tests/cassettes/test_get_device_code.yaml +22 -0
  136. cumulusci/oauth/tests/cassettes/test_get_device_oauth_token.yaml +74 -0
  137. cumulusci/oauth/tests/test_client.py +308 -0
  138. cumulusci/oauth/tests/test_salesforce.py +46 -0
  139. cumulusci/plugins/__init__.py +3 -0
  140. cumulusci/plugins/plugin_base.py +93 -0
  141. cumulusci/plugins/plugin_loader.py +59 -0
  142. cumulusci/robotframework/CumulusCI.py +340 -0
  143. cumulusci/robotframework/CumulusCI.robot +7 -0
  144. cumulusci/robotframework/Performance.py +165 -0
  145. cumulusci/robotframework/Salesforce.py +936 -0
  146. cumulusci/robotframework/Salesforce.robot +192 -0
  147. cumulusci/robotframework/SalesforceAPI.py +416 -0
  148. cumulusci/robotframework/SalesforcePlaywright.py +220 -0
  149. cumulusci/robotframework/SalesforcePlaywright.robot +40 -0
  150. cumulusci/robotframework/__init__.py +2 -0
  151. cumulusci/robotframework/base_library.py +39 -0
  152. cumulusci/robotframework/faker_mixin.py +89 -0
  153. cumulusci/robotframework/form_handlers.py +222 -0
  154. cumulusci/robotframework/javascript/cci_init.js +34 -0
  155. cumulusci/robotframework/javascript/cumulusci.js +4 -0
  156. cumulusci/robotframework/locator_manager.py +197 -0
  157. cumulusci/robotframework/locators_56.py +88 -0
  158. cumulusci/robotframework/locators_57.py +5 -0
  159. cumulusci/robotframework/pageobjects/BasePageObjects.py +433 -0
  160. cumulusci/robotframework/pageobjects/ObjectManagerPageObject.py +246 -0
  161. cumulusci/robotframework/pageobjects/PageObjectLibrary.py +45 -0
  162. cumulusci/robotframework/pageobjects/PageObjects.py +351 -0
  163. cumulusci/robotframework/pageobjects/__init__.py +12 -0
  164. cumulusci/robotframework/pageobjects/baseobjects.py +120 -0
  165. cumulusci/robotframework/perftests/short/collection_perf.robot +105 -0
  166. cumulusci/robotframework/tests/CustomObjectTestPage.py +10 -0
  167. cumulusci/robotframework/tests/FooTestPage.py +8 -0
  168. cumulusci/robotframework/tests/cumulusci/base.robot +40 -0
  169. cumulusci/robotframework/tests/cumulusci/bulkdata.robot +38 -0
  170. cumulusci/robotframework/tests/cumulusci/communities.robot +57 -0
  171. cumulusci/robotframework/tests/cumulusci/datagen.robot +84 -0
  172. cumulusci/robotframework/tests/salesforce/TestLibraryA.py +24 -0
  173. cumulusci/robotframework/tests/salesforce/TestLibraryB.py +20 -0
  174. cumulusci/robotframework/tests/salesforce/TestListener.py +93 -0
  175. cumulusci/robotframework/tests/salesforce/api.robot +178 -0
  176. cumulusci/robotframework/tests/salesforce/browsers.robot +143 -0
  177. cumulusci/robotframework/tests/salesforce/classic.robot +51 -0
  178. cumulusci/robotframework/tests/salesforce/create_contact.robot +59 -0
  179. cumulusci/robotframework/tests/salesforce/faker.robot +68 -0
  180. cumulusci/robotframework/tests/salesforce/forms.robot +172 -0
  181. cumulusci/robotframework/tests/salesforce/label_locator.robot +244 -0
  182. cumulusci/robotframework/tests/salesforce/labels.html +33 -0
  183. cumulusci/robotframework/tests/salesforce/locators.robot +149 -0
  184. cumulusci/robotframework/tests/salesforce/pageobjects/base_pageobjects.robot +100 -0
  185. cumulusci/robotframework/tests/salesforce/pageobjects/example_page_object.py +25 -0
  186. cumulusci/robotframework/tests/salesforce/pageobjects/listing_page.robot +115 -0
  187. cumulusci/robotframework/tests/salesforce/pageobjects/objectmanager.robot +74 -0
  188. cumulusci/robotframework/tests/salesforce/pageobjects/pageobjects.robot +171 -0
  189. cumulusci/robotframework/tests/salesforce/performance.robot +109 -0
  190. cumulusci/robotframework/tests/salesforce/playwright/javascript_keywords.robot +33 -0
  191. cumulusci/robotframework/tests/salesforce/playwright/open_test_browser.robot +48 -0
  192. cumulusci/robotframework/tests/salesforce/playwright/playwright.robot +24 -0
  193. cumulusci/robotframework/tests/salesforce/playwright/ui.robot +32 -0
  194. cumulusci/robotframework/tests/salesforce/populate.robot +89 -0
  195. cumulusci/robotframework/tests/salesforce/test_testlistener.py +37 -0
  196. cumulusci/robotframework/tests/salesforce/ui.robot +361 -0
  197. cumulusci/robotframework/tests/test_cumulusci_library.py +304 -0
  198. cumulusci/robotframework/tests/test_locator_manager.py +158 -0
  199. cumulusci/robotframework/tests/test_pageobjects.py +291 -0
  200. cumulusci/robotframework/tests/test_performance.py +38 -0
  201. cumulusci/robotframework/tests/test_salesforce.py +79 -0
  202. cumulusci/robotframework/tests/test_salesforce_locators.py +73 -0
  203. cumulusci/robotframework/tests/test_template_util.py +53 -0
  204. cumulusci/robotframework/tests/test_utils.py +106 -0
  205. cumulusci/robotframework/utils.py +283 -0
  206. cumulusci/salesforce_api/__init__.py +0 -0
  207. cumulusci/salesforce_api/exceptions.py +23 -0
  208. cumulusci/salesforce_api/filterable_objects.py +96 -0
  209. cumulusci/salesforce_api/mc_soap_envelopes.py +89 -0
  210. cumulusci/salesforce_api/metadata.py +721 -0
  211. cumulusci/salesforce_api/org_schema.py +571 -0
  212. cumulusci/salesforce_api/org_schema_models.py +226 -0
  213. cumulusci/salesforce_api/package_install.py +265 -0
  214. cumulusci/salesforce_api/package_zip.py +301 -0
  215. cumulusci/salesforce_api/rest_deploy.py +148 -0
  216. cumulusci/salesforce_api/retrieve_profile_api.py +301 -0
  217. cumulusci/salesforce_api/soap_envelopes.py +177 -0
  218. cumulusci/salesforce_api/tests/__init__.py +0 -0
  219. cumulusci/salesforce_api/tests/metadata_test_strings.py +24 -0
  220. cumulusci/salesforce_api/tests/test_metadata.py +1015 -0
  221. cumulusci/salesforce_api/tests/test_package_install.py +219 -0
  222. cumulusci/salesforce_api/tests/test_package_zip.py +380 -0
  223. cumulusci/salesforce_api/tests/test_rest_deploy.py +264 -0
  224. cumulusci/salesforce_api/tests/test_retrieve_profile_api.py +337 -0
  225. cumulusci/salesforce_api/tests/test_utils.py +124 -0
  226. cumulusci/salesforce_api/utils.py +51 -0
  227. cumulusci/schema/cumulusci.jsonschema.json +782 -0
  228. cumulusci/tasks/__init__.py +0 -0
  229. cumulusci/tasks/apex/__init__.py +0 -0
  230. cumulusci/tasks/apex/anon.py +157 -0
  231. cumulusci/tasks/apex/batch.py +180 -0
  232. cumulusci/tasks/apex/testrunner.py +835 -0
  233. cumulusci/tasks/apex/tests/cassettes/ManualEditTestApexIntegrationTests.test_run_tests__integration_test.yaml +703 -0
  234. cumulusci/tasks/apex/tests/test_apex_tasks.py +1558 -0
  235. cumulusci/tasks/base_source_control_task.py +17 -0
  236. cumulusci/tasks/bulkdata/__init__.py +15 -0
  237. cumulusci/tasks/bulkdata/base_generate_data_task.py +96 -0
  238. cumulusci/tasks/bulkdata/dates.py +97 -0
  239. cumulusci/tasks/bulkdata/delete.py +156 -0
  240. cumulusci/tasks/bulkdata/extract.py +441 -0
  241. cumulusci/tasks/bulkdata/extract_dataset_utils/calculate_dependencies.py +117 -0
  242. cumulusci/tasks/bulkdata/extract_dataset_utils/extract_yml.py +123 -0
  243. cumulusci/tasks/bulkdata/extract_dataset_utils/hardcoded_default_declarations.py +49 -0
  244. cumulusci/tasks/bulkdata/extract_dataset_utils/synthesize_extract_declarations.py +283 -0
  245. cumulusci/tasks/bulkdata/extract_dataset_utils/tests/test_extract_yml.py +142 -0
  246. cumulusci/tasks/bulkdata/extract_dataset_utils/tests/test_synthesize_extract_declarations.py +575 -0
  247. cumulusci/tasks/bulkdata/factory_utils.py +134 -0
  248. cumulusci/tasks/bulkdata/generate.py +4 -0
  249. cumulusci/tasks/bulkdata/generate_and_load_data.py +232 -0
  250. cumulusci/tasks/bulkdata/generate_and_load_data_from_yaml.py +19 -0
  251. cumulusci/tasks/bulkdata/generate_from_yaml.py +183 -0
  252. cumulusci/tasks/bulkdata/generate_mapping.py +434 -0
  253. cumulusci/tasks/bulkdata/generate_mapping_utils/dependency_map.py +169 -0
  254. cumulusci/tasks/bulkdata/generate_mapping_utils/extract_mapping_file_generator.py +45 -0
  255. cumulusci/tasks/bulkdata/generate_mapping_utils/generate_mapping_from_declarations.py +121 -0
  256. cumulusci/tasks/bulkdata/generate_mapping_utils/load_mapping_file_generator.py +127 -0
  257. cumulusci/tasks/bulkdata/generate_mapping_utils/mapping_generator_post_processes.py +53 -0
  258. cumulusci/tasks/bulkdata/generate_mapping_utils/mapping_transforms.py +139 -0
  259. cumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_generate_extract_mapping_from_declarations.py +135 -0
  260. cumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_generate_load_mapping_from_declarations.py +330 -0
  261. cumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_mapping_generator_post_processes.py +60 -0
  262. cumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_mapping_transforms.py +188 -0
  263. cumulusci/tasks/bulkdata/load.py +1196 -0
  264. cumulusci/tasks/bulkdata/mapping_parser.py +811 -0
  265. cumulusci/tasks/bulkdata/query_transformers.py +264 -0
  266. cumulusci/tasks/bulkdata/select_utils.py +792 -0
  267. cumulusci/tasks/bulkdata/snowfakery.py +753 -0
  268. cumulusci/tasks/bulkdata/snowfakery_utils/queue_manager.py +478 -0
  269. cumulusci/tasks/bulkdata/snowfakery_utils/snowfakery_run_until.py +141 -0
  270. cumulusci/tasks/bulkdata/snowfakery_utils/snowfakery_working_directory.py +53 -0
  271. cumulusci/tasks/bulkdata/snowfakery_utils/subtask_configurator.py +64 -0
  272. cumulusci/tasks/bulkdata/step.py +1242 -0
  273. cumulusci/tasks/bulkdata/tests/__init__.py +0 -0
  274. cumulusci/tasks/bulkdata/tests/cassettes/TestSelect.test_select_random_strategy.yaml +147 -0
  275. cumulusci/tasks/bulkdata/tests/cassettes/TestSelect.test_select_similarity_annoy_strategy.yaml +123 -0
  276. cumulusci/tasks/bulkdata/tests/cassettes/TestSelect.test_select_similarity_select_and_insert_strategy.yaml +313 -0
  277. cumulusci/tasks/bulkdata/tests/cassettes/TestSelect.test_select_similarity_select_and_insert_strategy_bulk.yaml +550 -0
  278. cumulusci/tasks/bulkdata/tests/cassettes/TestSelect.test_select_similarity_strategy.yaml +175 -0
  279. cumulusci/tasks/bulkdata/tests/cassettes/TestSelect.test_select_standard_strategy.yaml +147 -0
  280. cumulusci/tasks/bulkdata/tests/cassettes/TestSnowfakery.test_run_until_records_in_org__multiple_needed.yaml +69 -0
  281. cumulusci/tasks/bulkdata/tests/cassettes/TestSnowfakery.test_run_until_records_in_org__none_needed.yaml +22 -0
  282. cumulusci/tasks/bulkdata/tests/cassettes/TestSnowfakery.test_run_until_records_in_org__one_needed.yaml +24 -0
  283. cumulusci/tasks/bulkdata/tests/cassettes/TestSnowfakery.test_snowfakery_query_salesforce.yaml +25 -0
  284. cumulusci/tasks/bulkdata/tests/cassettes/TestUpdatesIntegrationTests.test_updates_task.yaml +80 -0
  285. cumulusci/tasks/bulkdata/tests/cassettes/TestUpsert.test_simple_upsert__rest.yaml +270 -0
  286. cumulusci/tasks/bulkdata/tests/cassettes/TestUpsert.test_upsert__rest.yaml +267 -0
  287. cumulusci/tasks/bulkdata/tests/cassettes/TestUpsert.test_upsert_complex_external_id_field__rest.yaml +369 -0
  288. cumulusci/tasks/bulkdata/tests/cassettes/TestUpsert.test_upsert_complex_external_id_field_rest__duplicate_error.yaml +204 -0
  289. cumulusci/tasks/bulkdata/tests/cassettes/TestUpsert.test_upsert_complex_fields__bulk.yaml +675 -0
  290. cumulusci/tasks/bulkdata/tests/dummy_data_factory.py +36 -0
  291. cumulusci/tasks/bulkdata/tests/integration_test_utils.py +49 -0
  292. cumulusci/tasks/bulkdata/tests/mapping-oid.yml +87 -0
  293. cumulusci/tasks/bulkdata/tests/mapping_after.yml +38 -0
  294. cumulusci/tasks/bulkdata/tests/mapping_poly.yml +34 -0
  295. cumulusci/tasks/bulkdata/tests/mapping_poly_incomplete.yml +20 -0
  296. cumulusci/tasks/bulkdata/tests/mapping_poly_wrong.yml +21 -0
  297. cumulusci/tasks/bulkdata/tests/mapping_select.yml +20 -0
  298. cumulusci/tasks/bulkdata/tests/mapping_select_invalid_strategy.yml +20 -0
  299. cumulusci/tasks/bulkdata/tests/mapping_select_invalid_threshold__invalid_number.yml +21 -0
  300. cumulusci/tasks/bulkdata/tests/mapping_select_invalid_threshold__invalid_strategy.yml +21 -0
  301. cumulusci/tasks/bulkdata/tests/mapping_select_invalid_threshold__non_float.yml +21 -0
  302. cumulusci/tasks/bulkdata/tests/mapping_select_missing_priority_fields.yml +22 -0
  303. cumulusci/tasks/bulkdata/tests/mapping_select_no_priority_fields.yml +18 -0
  304. cumulusci/tasks/bulkdata/tests/mapping_simple.yml +27 -0
  305. cumulusci/tasks/bulkdata/tests/mapping_v1.yml +28 -0
  306. cumulusci/tasks/bulkdata/tests/mapping_v2.yml +21 -0
  307. cumulusci/tasks/bulkdata/tests/mapping_v3.yml +32 -0
  308. cumulusci/tasks/bulkdata/tests/mapping_vanilla_sf.yml +69 -0
  309. cumulusci/tasks/bulkdata/tests/mock_data_factory_without_mapping.py +12 -0
  310. cumulusci/tasks/bulkdata/tests/person_accounts.yml +23 -0
  311. cumulusci/tasks/bulkdata/tests/person_accounts_minimal.yml +15 -0
  312. cumulusci/tasks/bulkdata/tests/recordtypes.yml +8 -0
  313. cumulusci/tasks/bulkdata/tests/recordtypes_2.yml +6 -0
  314. cumulusci/tasks/bulkdata/tests/recordtypes_with_ispersontype.yml +8 -0
  315. cumulusci/tasks/bulkdata/tests/snowfakery/child/child2.yml +3 -0
  316. cumulusci/tasks/bulkdata/tests/snowfakery/child.yml +4 -0
  317. cumulusci/tasks/bulkdata/tests/snowfakery/gen_npsp_standard_objects.recipe.yml +89 -0
  318. cumulusci/tasks/bulkdata/tests/snowfakery/include_parent.yml +3 -0
  319. cumulusci/tasks/bulkdata/tests/snowfakery/npsp_standard_objects_macros.yml +34 -0
  320. cumulusci/tasks/bulkdata/tests/snowfakery/options.recipe.yml +6 -0
  321. cumulusci/tasks/bulkdata/tests/snowfakery/query_snowfakery.recipe.yml +16 -0
  322. cumulusci/tasks/bulkdata/tests/snowfakery/sf_standard_object_macros.yml +83 -0
  323. cumulusci/tasks/bulkdata/tests/snowfakery/simple_snowfakery.load.yml +2 -0
  324. cumulusci/tasks/bulkdata/tests/snowfakery/simple_snowfakery.recipe.yml +13 -0
  325. cumulusci/tasks/bulkdata/tests/snowfakery/simple_snowfakery_2.load.yml +5 -0
  326. cumulusci/tasks/bulkdata/tests/snowfakery/simple_snowfakery_channels.load.yml +13 -0
  327. cumulusci/tasks/bulkdata/tests/snowfakery/simple_snowfakery_channels.recipe.yml +12 -0
  328. cumulusci/tasks/bulkdata/tests/snowfakery/simple_snowfakery_channels_2.load.yml +13 -0
  329. cumulusci/tasks/bulkdata/tests/snowfakery/unique_values.recipe.yml +4 -0
  330. cumulusci/tasks/bulkdata/tests/snowfakery/upsert.recipe.yml +23 -0
  331. cumulusci/tasks/bulkdata/tests/snowfakery/upsert_2.recipe.yml +29 -0
  332. cumulusci/tasks/bulkdata/tests/snowfakery/upsert_before.yml +10 -0
  333. cumulusci/tasks/bulkdata/tests/test_base_generate_data_tasks.py +61 -0
  334. cumulusci/tasks/bulkdata/tests/test_dates.py +99 -0
  335. cumulusci/tasks/bulkdata/tests/test_delete.py +404 -0
  336. cumulusci/tasks/bulkdata/tests/test_extract.py +1311 -0
  337. cumulusci/tasks/bulkdata/tests/test_factory_utils.py +55 -0
  338. cumulusci/tasks/bulkdata/tests/test_generate_and_load.py +252 -0
  339. cumulusci/tasks/bulkdata/tests/test_generate_from_snowfakery_task.py +343 -0
  340. cumulusci/tasks/bulkdata/tests/test_generatemapping.py +1039 -0
  341. cumulusci/tasks/bulkdata/tests/test_load.py +3175 -0
  342. cumulusci/tasks/bulkdata/tests/test_mapping_parser.py +1658 -0
  343. cumulusci/tasks/bulkdata/tests/test_query_db__joins_self_lookups.yml +12 -0
  344. cumulusci/tasks/bulkdata/tests/test_query_db_joins_lookups.yml +26 -0
  345. cumulusci/tasks/bulkdata/tests/test_query_db_joins_lookups_select.yml +48 -0
  346. cumulusci/tasks/bulkdata/tests/test_select.py +171 -0
  347. cumulusci/tasks/bulkdata/tests/test_select_utils.py +1057 -0
  348. cumulusci/tasks/bulkdata/tests/test_snowfakery.py +1153 -0
  349. cumulusci/tasks/bulkdata/tests/test_step.py +3957 -0
  350. cumulusci/tasks/bulkdata/tests/test_updates.py +513 -0
  351. cumulusci/tasks/bulkdata/tests/test_upsert.py +1015 -0
  352. cumulusci/tasks/bulkdata/tests/test_utils.py +158 -0
  353. cumulusci/tasks/bulkdata/tests/testdata.db +0 -0
  354. cumulusci/tasks/bulkdata/tests/update_describe.py +50 -0
  355. cumulusci/tasks/bulkdata/tests/update_person_accounts.yml +23 -0
  356. cumulusci/tasks/bulkdata/tests/utils.py +114 -0
  357. cumulusci/tasks/bulkdata/update_data.py +260 -0
  358. cumulusci/tasks/bulkdata/upsert_utils.py +130 -0
  359. cumulusci/tasks/bulkdata/utils.py +249 -0
  360. cumulusci/tasks/command.py +178 -0
  361. cumulusci/tasks/connectedapp.py +186 -0
  362. cumulusci/tasks/create_package_version.py +778 -0
  363. cumulusci/tasks/datadictionary.py +745 -0
  364. cumulusci/tasks/dx_convert_from.py +26 -0
  365. cumulusci/tasks/github/__init__.py +17 -0
  366. cumulusci/tasks/github/base.py +16 -0
  367. cumulusci/tasks/github/commit_status.py +13 -0
  368. cumulusci/tasks/github/merge.py +11 -0
  369. cumulusci/tasks/github/publish.py +11 -0
  370. cumulusci/tasks/github/pull_request.py +11 -0
  371. cumulusci/tasks/github/release.py +11 -0
  372. cumulusci/tasks/github/release_report.py +11 -0
  373. cumulusci/tasks/github/tag.py +11 -0
  374. cumulusci/tasks/github/tests/__init__.py +0 -0
  375. cumulusci/tasks/github/tests/test_util.py +202 -0
  376. cumulusci/tasks/github/tests/test_vcs_migration.py +44 -0
  377. cumulusci/tasks/github/tests/util_github_api.py +666 -0
  378. cumulusci/tasks/github/util.py +252 -0
  379. cumulusci/tasks/marketing_cloud/__init__.py +0 -0
  380. cumulusci/tasks/marketing_cloud/api.py +188 -0
  381. cumulusci/tasks/marketing_cloud/base.py +38 -0
  382. cumulusci/tasks/marketing_cloud/deploy.py +345 -0
  383. cumulusci/tasks/marketing_cloud/get_user_info.py +40 -0
  384. cumulusci/tasks/marketing_cloud/mc_constants.py +1 -0
  385. cumulusci/tasks/marketing_cloud/tests/__init__.py +0 -0
  386. cumulusci/tasks/marketing_cloud/tests/conftest.py +46 -0
  387. cumulusci/tasks/marketing_cloud/tests/expected-payload.json +110 -0
  388. cumulusci/tasks/marketing_cloud/tests/test_api.py +97 -0
  389. cumulusci/tasks/marketing_cloud/tests/test_api_soap_envelopes.py +145 -0
  390. cumulusci/tasks/marketing_cloud/tests/test_base.py +14 -0
  391. cumulusci/tasks/marketing_cloud/tests/test_deploy.py +400 -0
  392. cumulusci/tasks/marketing_cloud/tests/test_get_user_info.py +141 -0
  393. cumulusci/tasks/marketing_cloud/tests/validation-response.json +39 -0
  394. cumulusci/tasks/metadata/__init__.py +0 -0
  395. cumulusci/tasks/metadata/ee_src.py +94 -0
  396. cumulusci/tasks/metadata/managed_src.py +100 -0
  397. cumulusci/tasks/metadata/metadata_map.yml +868 -0
  398. cumulusci/tasks/metadata/modify.py +99 -0
  399. cumulusci/tasks/metadata/package.py +684 -0
  400. cumulusci/tasks/metadata/tests/__init__.py +0 -0
  401. cumulusci/tasks/metadata/tests/package_metadata/namespaced_report_folder/.hidden/.keep +0 -0
  402. cumulusci/tasks/metadata/tests/package_metadata/namespaced_report_folder/destructiveChanges.xml +9 -0
  403. cumulusci/tasks/metadata/tests/package_metadata/namespaced_report_folder/package.xml +9 -0
  404. cumulusci/tasks/metadata/tests/package_metadata/namespaced_report_folder/package_install_uninstall.xml +11 -0
  405. cumulusci/tasks/metadata/tests/package_metadata/namespaced_report_folder/reports/namespace__TestFolder/TestReport.report +3 -0
  406. cumulusci/tasks/metadata/tests/sample_package.xml +9 -0
  407. cumulusci/tasks/metadata/tests/test_ee_src.py +112 -0
  408. cumulusci/tasks/metadata/tests/test_managed_src.py +111 -0
  409. cumulusci/tasks/metadata/tests/test_modify.py +123 -0
  410. cumulusci/tasks/metadata/tests/test_package.py +476 -0
  411. cumulusci/tasks/metadata_etl/__init__.py +29 -0
  412. cumulusci/tasks/metadata_etl/base.py +436 -0
  413. cumulusci/tasks/metadata_etl/duplicate_rules.py +24 -0
  414. cumulusci/tasks/metadata_etl/field_sets.py +70 -0
  415. cumulusci/tasks/metadata_etl/help_text.py +92 -0
  416. cumulusci/tasks/metadata_etl/layouts.py +550 -0
  417. cumulusci/tasks/metadata_etl/objects.py +68 -0
  418. cumulusci/tasks/metadata_etl/permissions.py +167 -0
  419. cumulusci/tasks/metadata_etl/picklists.py +221 -0
  420. cumulusci/tasks/metadata_etl/remote_site_settings.py +99 -0
  421. cumulusci/tasks/metadata_etl/sharing.py +138 -0
  422. cumulusci/tasks/metadata_etl/tests/test_base.py +512 -0
  423. cumulusci/tasks/metadata_etl/tests/test_duplicate_rules.py +22 -0
  424. cumulusci/tasks/metadata_etl/tests/test_field_sets.py +156 -0
  425. cumulusci/tasks/metadata_etl/tests/test_help_text.py +387 -0
  426. cumulusci/tasks/metadata_etl/tests/test_ip_ranges.py +85 -0
  427. cumulusci/tasks/metadata_etl/tests/test_layouts.py +858 -0
  428. cumulusci/tasks/metadata_etl/tests/test_objects.py +236 -0
  429. cumulusci/tasks/metadata_etl/tests/test_permissions.py +223 -0
  430. cumulusci/tasks/metadata_etl/tests/test_picklists.py +547 -0
  431. cumulusci/tasks/metadata_etl/tests/test_remote_site_settings.py +46 -0
  432. cumulusci/tasks/metadata_etl/tests/test_sharing.py +333 -0
  433. cumulusci/tasks/metadata_etl/tests/test_value_sets.py +298 -0
  434. cumulusci/tasks/metadata_etl/value_sets.py +106 -0
  435. cumulusci/tasks/metadeploy.py +393 -0
  436. cumulusci/tasks/metaxml.py +88 -0
  437. cumulusci/tasks/preflight/__init__.py +0 -0
  438. cumulusci/tasks/preflight/dataset_load.py +49 -0
  439. cumulusci/tasks/preflight/licenses.py +86 -0
  440. cumulusci/tasks/preflight/packages.py +14 -0
  441. cumulusci/tasks/preflight/permsets.py +23 -0
  442. cumulusci/tasks/preflight/recordtypes.py +16 -0
  443. cumulusci/tasks/preflight/retrieve_tasks.py +30 -0
  444. cumulusci/tasks/preflight/settings.py +77 -0
  445. cumulusci/tasks/preflight/sobjects.py +202 -0
  446. cumulusci/tasks/preflight/tests/test_dataset_load.py +85 -0
  447. cumulusci/tasks/preflight/tests/test_licenses.py +174 -0
  448. cumulusci/tasks/preflight/tests/test_packages.py +14 -0
  449. cumulusci/tasks/preflight/tests/test_permset_preflights.py +51 -0
  450. cumulusci/tasks/preflight/tests/test_recordtypes.py +30 -0
  451. cumulusci/tasks/preflight/tests/test_retrieve_tasks.py +62 -0
  452. cumulusci/tasks/preflight/tests/test_settings.py +130 -0
  453. cumulusci/tasks/preflight/tests/test_sobjects.py +231 -0
  454. cumulusci/tasks/push/README.md +59 -0
  455. cumulusci/tasks/push/__init__.py +0 -0
  456. cumulusci/tasks/push/push_api.py +659 -0
  457. cumulusci/tasks/push/pushfails.py +136 -0
  458. cumulusci/tasks/push/tasks.py +476 -0
  459. cumulusci/tasks/push/tests/conftest.py +263 -0
  460. cumulusci/tasks/push/tests/test_push_api.py +951 -0
  461. cumulusci/tasks/push/tests/test_push_tasks.py +659 -0
  462. cumulusci/tasks/release_notes/README.md +63 -0
  463. cumulusci/tasks/release_notes/__init__.py +0 -0
  464. cumulusci/tasks/release_notes/exceptions.py +5 -0
  465. cumulusci/tasks/release_notes/generator.py +137 -0
  466. cumulusci/tasks/release_notes/parser.py +232 -0
  467. cumulusci/tasks/release_notes/provider.py +44 -0
  468. cumulusci/tasks/release_notes/task.py +300 -0
  469. cumulusci/tasks/release_notes/tests/__init__.py +0 -0
  470. cumulusci/tasks/release_notes/tests/change_notes/full/example1.md +17 -0
  471. cumulusci/tasks/release_notes/tests/change_notes/multi/1.txt +1 -0
  472. cumulusci/tasks/release_notes/tests/change_notes/multi/2.txt +1 -0
  473. cumulusci/tasks/release_notes/tests/change_notes/multi/3.txt +1 -0
  474. cumulusci/tasks/release_notes/tests/change_notes/single/1.txt +1 -0
  475. cumulusci/tasks/release_notes/tests/test_generator.py +582 -0
  476. cumulusci/tasks/release_notes/tests/test_parser.py +867 -0
  477. cumulusci/tasks/release_notes/tests/test_provider.py +512 -0
  478. cumulusci/tasks/release_notes/tests/test_task.py +461 -0
  479. cumulusci/tasks/release_notes/tests/utils.py +153 -0
  480. cumulusci/tasks/robotframework/__init__.py +3 -0
  481. cumulusci/tasks/robotframework/debugger/DebugListener.py +100 -0
  482. cumulusci/tasks/robotframework/debugger/__init__.py +10 -0
  483. cumulusci/tasks/robotframework/debugger/model.py +87 -0
  484. cumulusci/tasks/robotframework/debugger/ui.py +259 -0
  485. cumulusci/tasks/robotframework/libdoc.py +269 -0
  486. cumulusci/tasks/robotframework/robotframework.py +392 -0
  487. cumulusci/tasks/robotframework/stylesheet.css +130 -0
  488. cumulusci/tasks/robotframework/template.html +109 -0
  489. cumulusci/tasks/robotframework/tests/TestLibrary.py +18 -0
  490. cumulusci/tasks/robotframework/tests/TestPageObjects.py +31 -0
  491. cumulusci/tasks/robotframework/tests/TestResource.robot +8 -0
  492. cumulusci/tasks/robotframework/tests/failing_tests.robot +16 -0
  493. cumulusci/tasks/robotframework/tests/performance.robot +23 -0
  494. cumulusci/tasks/robotframework/tests/test_browser_proxies.py +137 -0
  495. cumulusci/tasks/robotframework/tests/test_debugger.py +360 -0
  496. cumulusci/tasks/robotframework/tests/test_robot_parallel.py +141 -0
  497. cumulusci/tasks/robotframework/tests/test_robotframework.py +860 -0
  498. cumulusci/tasks/salesforce/BaseRetrieveMetadata.py +58 -0
  499. cumulusci/tasks/salesforce/BaseSalesforceApiTask.py +45 -0
  500. cumulusci/tasks/salesforce/BaseSalesforceMetadataApiTask.py +18 -0
  501. cumulusci/tasks/salesforce/BaseSalesforceTask.py +4 -0
  502. cumulusci/tasks/salesforce/BaseUninstallMetadata.py +41 -0
  503. cumulusci/tasks/salesforce/CreateCommunity.py +124 -0
  504. cumulusci/tasks/salesforce/CreatePackage.py +29 -0
  505. cumulusci/tasks/salesforce/Deploy.py +240 -0
  506. cumulusci/tasks/salesforce/DeployBundles.py +88 -0
  507. cumulusci/tasks/salesforce/DescribeMetadataTypes.py +26 -0
  508. cumulusci/tasks/salesforce/EnsureRecordTypes.py +202 -0
  509. cumulusci/tasks/salesforce/GetInstalledPackages.py +8 -0
  510. cumulusci/tasks/salesforce/ListCommunities.py +40 -0
  511. cumulusci/tasks/salesforce/ListCommunityTemplates.py +19 -0
  512. cumulusci/tasks/salesforce/PublishCommunity.py +62 -0
  513. cumulusci/tasks/salesforce/RetrievePackaged.py +41 -0
  514. cumulusci/tasks/salesforce/RetrieveReportsAndDashboards.py +82 -0
  515. cumulusci/tasks/salesforce/RetrieveUnpackaged.py +36 -0
  516. cumulusci/tasks/salesforce/SOQLQuery.py +39 -0
  517. cumulusci/tasks/salesforce/UninstallLocal.py +15 -0
  518. cumulusci/tasks/salesforce/UninstallLocalBundles.py +28 -0
  519. cumulusci/tasks/salesforce/UninstallLocalNamespacedBundles.py +58 -0
  520. cumulusci/tasks/salesforce/UninstallPackage.py +32 -0
  521. cumulusci/tasks/salesforce/UninstallPackaged.py +56 -0
  522. cumulusci/tasks/salesforce/UpdateAdminProfile.py +8 -0
  523. cumulusci/tasks/salesforce/__init__.py +79 -0
  524. cumulusci/tasks/salesforce/activate_flow.py +74 -0
  525. cumulusci/tasks/salesforce/check_components.py +324 -0
  526. cumulusci/tasks/salesforce/composite.py +142 -0
  527. cumulusci/tasks/salesforce/create_permission_sets.py +35 -0
  528. cumulusci/tasks/salesforce/custom_settings.py +134 -0
  529. cumulusci/tasks/salesforce/custom_settings_wait.py +132 -0
  530. cumulusci/tasks/salesforce/enable_prediction.py +107 -0
  531. cumulusci/tasks/salesforce/insert_record.py +40 -0
  532. cumulusci/tasks/salesforce/install_package_version.py +242 -0
  533. cumulusci/tasks/salesforce/license_preflights.py +8 -0
  534. cumulusci/tasks/salesforce/network_member_group.py +178 -0
  535. cumulusci/tasks/salesforce/nonsourcetracking.py +228 -0
  536. cumulusci/tasks/salesforce/org_settings.py +193 -0
  537. cumulusci/tasks/salesforce/package_upload.py +328 -0
  538. cumulusci/tasks/salesforce/profiles.py +74 -0
  539. cumulusci/tasks/salesforce/promote_package_version.py +376 -0
  540. cumulusci/tasks/salesforce/retrieve_profile.py +195 -0
  541. cumulusci/tasks/salesforce/salesforce_files.py +244 -0
  542. cumulusci/tasks/salesforce/sourcetracking.py +507 -0
  543. cumulusci/tasks/salesforce/tests/__init__.py +3 -0
  544. cumulusci/tasks/salesforce/tests/test_CreateCommunity.py +278 -0
  545. cumulusci/tasks/salesforce/tests/test_CreatePackage.py +22 -0
  546. cumulusci/tasks/salesforce/tests/test_Deploy.py +470 -0
  547. cumulusci/tasks/salesforce/tests/test_DeployBundles.py +76 -0
  548. cumulusci/tasks/salesforce/tests/test_EnsureRecordTypes.py +345 -0
  549. cumulusci/tasks/salesforce/tests/test_ListCommunities.py +84 -0
  550. cumulusci/tasks/salesforce/tests/test_ListCommunityTemplates.py +49 -0
  551. cumulusci/tasks/salesforce/tests/test_PackageUpload.py +547 -0
  552. cumulusci/tasks/salesforce/tests/test_ProfileGrantAllAccess.py +699 -0
  553. cumulusci/tasks/salesforce/tests/test_PublishCommunity.py +181 -0
  554. cumulusci/tasks/salesforce/tests/test_RetrievePackaged.py +24 -0
  555. cumulusci/tasks/salesforce/tests/test_RetrieveReportsAndDashboards.py +56 -0
  556. cumulusci/tasks/salesforce/tests/test_RetrieveUnpackaged.py +21 -0
  557. cumulusci/tasks/salesforce/tests/test_SOQLQuery.py +30 -0
  558. cumulusci/tasks/salesforce/tests/test_UninstallLocal.py +15 -0
  559. cumulusci/tasks/salesforce/tests/test_UninstallLocalBundles.py +19 -0
  560. cumulusci/tasks/salesforce/tests/test_UninstallLocalNamespacedBundles.py +22 -0
  561. cumulusci/tasks/salesforce/tests/test_UninstallPackage.py +19 -0
  562. cumulusci/tasks/salesforce/tests/test_UninstallPackaged.py +66 -0
  563. cumulusci/tasks/salesforce/tests/test_UninstallPackagedIncremental.py +127 -0
  564. cumulusci/tasks/salesforce/tests/test_activate_flow.py +132 -0
  565. cumulusci/tasks/salesforce/tests/test_base_tasks.py +110 -0
  566. cumulusci/tasks/salesforce/tests/test_check_components.py +445 -0
  567. cumulusci/tasks/salesforce/tests/test_composite.py +250 -0
  568. cumulusci/tasks/salesforce/tests/test_create_permission_sets.py +41 -0
  569. cumulusci/tasks/salesforce/tests/test_custom_settings.py +227 -0
  570. cumulusci/tasks/salesforce/tests/test_custom_settings_wait.py +174 -0
  571. cumulusci/tasks/salesforce/tests/test_describemetadatatypes.py +18 -0
  572. cumulusci/tasks/salesforce/tests/test_enable_prediction.py +240 -0
  573. cumulusci/tasks/salesforce/tests/test_insert_record.py +110 -0
  574. cumulusci/tasks/salesforce/tests/test_install_package_version.py +464 -0
  575. cumulusci/tasks/salesforce/tests/test_network_member_group.py +444 -0
  576. cumulusci/tasks/salesforce/tests/test_nonsourcetracking.py +235 -0
  577. cumulusci/tasks/salesforce/tests/test_org_settings.py +407 -0
  578. cumulusci/tasks/salesforce/tests/test_profiles.py +202 -0
  579. cumulusci/tasks/salesforce/tests/test_retrieve_profile.py +287 -0
  580. cumulusci/tasks/salesforce/tests/test_salesforce_files.py +228 -0
  581. cumulusci/tasks/salesforce/tests/test_sourcetracking.py +350 -0
  582. cumulusci/tasks/salesforce/tests/test_trigger_handlers.py +300 -0
  583. cumulusci/tasks/salesforce/tests/test_update_dependencies.py +509 -0
  584. cumulusci/tasks/salesforce/tests/util.py +79 -0
  585. cumulusci/tasks/salesforce/trigger_handlers.py +119 -0
  586. cumulusci/tasks/salesforce/uninstall_packaged_incremental.py +136 -0
  587. cumulusci/tasks/salesforce/update_dependencies.py +290 -0
  588. cumulusci/tasks/salesforce/update_profile.py +339 -0
  589. cumulusci/tasks/salesforce/users/permsets.py +227 -0
  590. cumulusci/tasks/salesforce/users/photos.py +162 -0
  591. cumulusci/tasks/salesforce/users/tests/photo.mock.txt +1 -0
  592. cumulusci/tasks/salesforce/users/tests/test_permsets.py +950 -0
  593. cumulusci/tasks/salesforce/users/tests/test_photos.py +373 -0
  594. cumulusci/tasks/sample_data/capture_sample_data.py +77 -0
  595. cumulusci/tasks/sample_data/load_sample_data.py +85 -0
  596. cumulusci/tasks/sample_data/test_capture_sample_data.py +117 -0
  597. cumulusci/tasks/sample_data/test_load_sample_data.py +121 -0
  598. cumulusci/tasks/sfdx.py +83 -0
  599. cumulusci/tasks/tests/__init__.py +1 -0
  600. cumulusci/tasks/tests/conftest.py +30 -0
  601. cumulusci/tasks/tests/test_command.py +129 -0
  602. cumulusci/tasks/tests/test_connectedapp.py +236 -0
  603. cumulusci/tasks/tests/test_create_package_version.py +847 -0
  604. cumulusci/tasks/tests/test_datadictionary.py +1575 -0
  605. cumulusci/tasks/tests/test_dx_convert_from.py +60 -0
  606. cumulusci/tasks/tests/test_metadeploy.py +624 -0
  607. cumulusci/tasks/tests/test_metaxml.py +99 -0
  608. cumulusci/tasks/tests/test_promote_package_version.py +488 -0
  609. cumulusci/tasks/tests/test_pushfails.py +96 -0
  610. cumulusci/tasks/tests/test_salesforce.py +72 -0
  611. cumulusci/tasks/tests/test_sfdx.py +105 -0
  612. cumulusci/tasks/tests/test_util.py +207 -0
  613. cumulusci/tasks/util.py +261 -0
  614. cumulusci/tasks/vcs/__init__.py +19 -0
  615. cumulusci/tasks/vcs/commit_status.py +58 -0
  616. cumulusci/tasks/vcs/create_commit_status.py +37 -0
  617. cumulusci/tasks/vcs/download_extract.py +199 -0
  618. cumulusci/tasks/vcs/merge.py +298 -0
  619. cumulusci/tasks/vcs/publish.py +207 -0
  620. cumulusci/tasks/vcs/pull_request.py +9 -0
  621. cumulusci/tasks/vcs/release.py +134 -0
  622. cumulusci/tasks/vcs/release_report.py +105 -0
  623. cumulusci/tasks/vcs/tag.py +31 -0
  624. cumulusci/tasks/vcs/tests/github/test_commit_status.py +196 -0
  625. cumulusci/tasks/vcs/tests/github/test_download_extract.py +896 -0
  626. cumulusci/tasks/vcs/tests/github/test_merge.py +1118 -0
  627. cumulusci/tasks/vcs/tests/github/test_publish.py +823 -0
  628. cumulusci/tasks/vcs/tests/github/test_pull_request.py +29 -0
  629. cumulusci/tasks/vcs/tests/github/test_release.py +390 -0
  630. cumulusci/tasks/vcs/tests/github/test_release_report.py +109 -0
  631. cumulusci/tasks/vcs/tests/github/test_tag.py +90 -0
  632. cumulusci/tasks/vlocity/exceptions.py +2 -0
  633. cumulusci/tasks/vlocity/tests/test_vlocity.py +283 -0
  634. cumulusci/tasks/vlocity/vlocity.py +342 -0
  635. cumulusci/tests/__init__.py +1 -0
  636. cumulusci/tests/cassettes/GET_sobjects_Account_PersonAccount_describe.yaml +18 -0
  637. cumulusci/tests/cassettes/TestIntegrationInfrastructure.test_integration_tests.yaml +19 -0
  638. cumulusci/tests/pytest_plugins/pytest_sf_orgconnect.py +307 -0
  639. cumulusci/tests/pytest_plugins/pytest_sf_vcr.py +275 -0
  640. cumulusci/tests/pytest_plugins/pytest_sf_vcr_serializer.py +160 -0
  641. cumulusci/tests/pytest_plugins/pytest_typeguard.py +5 -0
  642. cumulusci/tests/pytest_plugins/test_vcr_string_compressor.py +49 -0
  643. cumulusci/tests/pytest_plugins/vcr_string_compressor.py +97 -0
  644. cumulusci/tests/shared_cassettes/GET_sobjects_Account_describe.yaml +18 -0
  645. cumulusci/tests/shared_cassettes/GET_sobjects_Case_describe.yaml +18 -0
  646. cumulusci/tests/shared_cassettes/GET_sobjects_Contact_describe.yaml +4838 -0
  647. cumulusci/tests/shared_cassettes/GET_sobjects_Custom__c_describe.yaml +242 -0
  648. cumulusci/tests/shared_cassettes/GET_sobjects_Event_describe.yaml +19 -0
  649. cumulusci/tests/shared_cassettes/GET_sobjects_Global_describe.yaml +1338 -0
  650. cumulusci/tests/shared_cassettes/GET_sobjects_Lead_describe.yaml +18 -0
  651. cumulusci/tests/shared_cassettes/GET_sobjects_OpportunityContactRole_describe.yaml +34 -0
  652. cumulusci/tests/shared_cassettes/GET_sobjects_Opportunity_describe.yaml +1261 -0
  653. cumulusci/tests/shared_cassettes/GET_sobjects_Organization.yaml +49 -0
  654. cumulusci/tests/shared_cassettes/vcr_string_templates/batchInfoList_xml.tpl +15 -0
  655. cumulusci/tests/shared_cassettes/vcr_string_templates/batchInfo_xml.tpl +13 -0
  656. cumulusci/tests/shared_cassettes/vcr_string_templates/jobInfo_insert_xml.tpl +24 -0
  657. cumulusci/tests/shared_cassettes/vcr_string_templates/jobInfo_upsert_xml.tpl +25 -0
  658. cumulusci/tests/test_entry_points.py +20 -0
  659. cumulusci/tests/test_integration_infrastructure.py +131 -0
  660. cumulusci/tests/test_main.py +9 -0
  661. cumulusci/tests/test_schema.py +32 -0
  662. cumulusci/tests/test_utils.py +657 -0
  663. cumulusci/tests/test_vcr_serializer.py +134 -0
  664. cumulusci/tests/uncompressed_cassette.yaml +83 -0
  665. cumulusci/tests/util.py +344 -0
  666. cumulusci/utils/__init__.py +731 -0
  667. cumulusci/utils/classutils.py +9 -0
  668. cumulusci/utils/collections.py +32 -0
  669. cumulusci/utils/deprecation.py +11 -0
  670. cumulusci/utils/encryption.py +31 -0
  671. cumulusci/utils/fileutils.py +295 -0
  672. cumulusci/utils/git.py +142 -0
  673. cumulusci/utils/http/multi_request.py +214 -0
  674. cumulusci/utils/http/requests_utils.py +103 -0
  675. cumulusci/utils/http/tests/cassettes/ManualEditTestCompositeParallelSalesforce.test_http_headers.yaml +32 -0
  676. cumulusci/utils/http/tests/cassettes/TestCompositeParallelSalesforce.test_composite_parallel_salesforce.yaml +65 -0
  677. cumulusci/utils/http/tests/cassettes/TestCompositeParallelSalesforce.test_errors.yaml +24 -0
  678. cumulusci/utils/http/tests/cassettes/TestCompositeParallelSalesforce.test_reference_ids.yaml +49 -0
  679. cumulusci/utils/http/tests/test_multi_request.py +255 -0
  680. cumulusci/utils/iterators.py +21 -0
  681. cumulusci/utils/logging.py +128 -0
  682. cumulusci/utils/metaprogramming.py +10 -0
  683. cumulusci/utils/options.py +138 -0
  684. cumulusci/utils/parallel/queries_in_parallel/run_queries_in_parallel.py +29 -0
  685. cumulusci/utils/parallel/queries_in_parallel/tests/test_run_queries_in_parallel.py +50 -0
  686. cumulusci/utils/parallel/task_worker_queues/parallel_worker.py +238 -0
  687. cumulusci/utils/parallel/task_worker_queues/parallel_worker_queue.py +243 -0
  688. cumulusci/utils/parallel/task_worker_queues/tests/test_parallel_worker.py +353 -0
  689. cumulusci/utils/salesforce/count_sobjects.py +46 -0
  690. cumulusci/utils/salesforce/soql.py +17 -0
  691. cumulusci/utils/salesforce/tests/cassettes/ManualEdit_TestCountSObjects.test_count_sobjects__network_errors.yaml +23 -0
  692. cumulusci/utils/salesforce/tests/cassettes/TestCountSObjects.test_count_sobjects__errors.yaml +33 -0
  693. cumulusci/utils/salesforce/tests/cassettes/TestCountSObjects.test_count_sobjects_simple.yaml +29 -0
  694. cumulusci/utils/salesforce/tests/test_count_sobjects.py +29 -0
  695. cumulusci/utils/salesforce/tests/test_soql.py +30 -0
  696. cumulusci/utils/tests/cassettes/ManualEditTestDescribeOrg.test_minimal_schema.yaml +36 -0
  697. cumulusci/utils/tests/cassettes/ManualEdit_test_describe_to_sql.yaml +191 -0
  698. cumulusci/utils/tests/test_fileutils.py +284 -0
  699. cumulusci/utils/tests/test_git.py +85 -0
  700. cumulusci/utils/tests/test_logging.py +70 -0
  701. cumulusci/utils/tests/test_option_parsing.py +188 -0
  702. cumulusci/utils/tests/test_org_schema.py +691 -0
  703. cumulusci/utils/tests/test_org_schema_models.py +79 -0
  704. cumulusci/utils/tests/test_waiting.py +25 -0
  705. cumulusci/utils/version_strings.py +391 -0
  706. cumulusci/utils/waiting.py +42 -0
  707. cumulusci/utils/xml/__init__.py +91 -0
  708. cumulusci/utils/xml/metadata_tree.py +299 -0
  709. cumulusci/utils/xml/robot_xml.py +114 -0
  710. cumulusci/utils/xml/salesforce_encoding.py +100 -0
  711. cumulusci/utils/xml/test/test_metadata_tree.py +251 -0
  712. cumulusci/utils/xml/test/test_salesforce_encoding.py +173 -0
  713. cumulusci/utils/yaml/cumulusci_yml.py +401 -0
  714. cumulusci/utils/yaml/model_parser.py +156 -0
  715. cumulusci/utils/yaml/safer_loader.py +74 -0
  716. cumulusci/utils/yaml/tests/bad_cci.yml +5 -0
  717. cumulusci/utils/yaml/tests/cassettes/TestCumulusciYml.test_validate_url__with_errors.yaml +20 -0
  718. cumulusci/utils/yaml/tests/test_cumulusci_yml.py +286 -0
  719. cumulusci/utils/yaml/tests/test_model_parser.py +175 -0
  720. cumulusci/utils/yaml/tests/test_safer_loader.py +88 -0
  721. cumulusci/utils/ziputils.py +61 -0
  722. cumulusci/vcs/base.py +143 -0
  723. cumulusci/vcs/bootstrap.py +272 -0
  724. cumulusci/vcs/github/__init__.py +24 -0
  725. cumulusci/vcs/github/adapter.py +689 -0
  726. cumulusci/vcs/github/release_notes/generator.py +219 -0
  727. cumulusci/vcs/github/release_notes/parser.py +151 -0
  728. cumulusci/vcs/github/release_notes/provider.py +143 -0
  729. cumulusci/vcs/github/service.py +569 -0
  730. cumulusci/vcs/github/tests/test_adapter.py +138 -0
  731. cumulusci/vcs/github/tests/test_service.py +408 -0
  732. cumulusci/vcs/models.py +586 -0
  733. cumulusci/vcs/tests/conftest.py +41 -0
  734. cumulusci/vcs/tests/dummy_service.py +241 -0
  735. cumulusci/vcs/tests/test_vcs_base.py +687 -0
  736. cumulusci/vcs/tests/test_vcs_bootstrap.py +727 -0
  737. cumulusci/vcs/utils/__init__.py +31 -0
  738. cumulusci/vcs/vcs_source.py +287 -0
  739. cumulusci_plus-5.0.0.dist-info/METADATA +145 -0
  740. cumulusci_plus-5.0.0.dist-info/RECORD +744 -0
  741. cumulusci_plus-5.0.0.dist-info/WHEEL +4 -0
  742. cumulusci_plus-5.0.0.dist-info/entry_points.txt +3 -0
  743. cumulusci_plus-5.0.0.dist-info/licenses/AUTHORS.rst +41 -0
  744. cumulusci_plus-5.0.0.dist-info/licenses/LICENSE +30 -0
@@ -0,0 +1,1438 @@
1
+ import io
2
+ import json
3
+ from datetime import date, datetime, timedelta
4
+ from pathlib import Path
5
+ from unittest import mock
6
+
7
+ import click
8
+ import pytest
9
+ import responses
10
+
11
+ from cumulusci.core.config import (
12
+ BaseProjectConfig,
13
+ OrgConfig,
14
+ ScratchOrgConfig,
15
+ ServiceConfig,
16
+ UniversalConfig,
17
+ )
18
+ from cumulusci.core.config.sfdx_org_config import SfdxOrgConfig
19
+ from cumulusci.core.exceptions import (
20
+ OrgNotFound,
21
+ ScratchOrgException,
22
+ ServiceNotConfigured,
23
+ )
24
+ from cumulusci.core.keychain import BaseProjectKeychain
25
+ from cumulusci.core.tests.utils import MockLookup
26
+ from cumulusci.tests.util import CURRENT_SF_API_VERSION
27
+ from cumulusci.utils import parse_api_datetime
28
+
29
+ from .. import org
30
+ from .utils import run_cli_command, run_click_command
31
+
32
+
33
+ class TestOrgCommands:
34
+ @mock.patch("webbrowser.open")
35
+ def test_org_browser(self, browser_open):
36
+ org_config = mock.Mock()
37
+ runtime = mock.Mock()
38
+ runtime.get_org.return_value = ("test", org_config)
39
+
40
+ run_click_command(
41
+ org.org_browser, runtime=runtime, org_name="test", path=None, url_only=False
42
+ )
43
+
44
+ org_config.refresh_oauth_token.assert_called_once()
45
+ browser_open.assert_called_once()
46
+ org_config.save.assert_called_once_with()
47
+
48
+ @mock.patch("webbrowser.open")
49
+ def test_org_browser_path(self, browser_open):
50
+ start_url = "https://random-word-1234-dev-ed.cs42.my.salesforce.com//secur/frontdoor.jsp?sid=00Dorgid!longtoken"
51
+ target_path = "/lightning/setup/Package/home"
52
+
53
+ org_config = mock.Mock()
54
+ org_config.start_url = start_url
55
+ runtime = mock.Mock()
56
+ runtime.get_org.return_value = ("test", org_config)
57
+
58
+ run_click_command(
59
+ org.org_browser,
60
+ runtime=runtime,
61
+ org_name="test",
62
+ path=target_path,
63
+ url_only=False,
64
+ )
65
+
66
+ org_config.refresh_oauth_token.assert_called_once()
67
+ expected_query = "&retURL=%2Flightning%2Fsetup%2FPackage%2Fhome"
68
+ browser_open.assert_called_once_with(start_url + expected_query)
69
+ org_config.save.assert_called_once_with()
70
+
71
+ @mock.patch("click.echo")
72
+ @mock.patch("webbrowser.open")
73
+ def test_org_browser_url_only(self, browser_open, click_echo):
74
+ start_url = "https://random-word-1234-dev-ed.cs42.my.salesforce.com//secur/frontdoor.jsp?sid=00Dorgid!longtoken"
75
+ org_config = mock.Mock()
76
+ org_config.start_url = start_url
77
+ runtime = mock.Mock()
78
+ runtime.get_org.return_value = ("test", org_config)
79
+
80
+ run_click_command(
81
+ org.org_browser,
82
+ runtime=runtime,
83
+ org_name="test",
84
+ path=None,
85
+ url_only=True,
86
+ )
87
+
88
+ org_config.refresh_oauth_token.assert_called_once()
89
+ browser_open.assert_not_called()
90
+ click_echo.assert_called_once_with(start_url)
91
+ org_config.save.assert_called_once_with()
92
+
93
+ @mock.patch("cumulusci.oauth.client.OAuth2Client.auth_code_flow")
94
+ @responses.activate
95
+ def test_org_connect(self, auth_code_flow):
96
+ auth_code_flow.return_value = {
97
+ "instance_url": "https://instance",
98
+ "access_token": "BOGUS",
99
+ "id": "OODxxxxxxxxxxxx/user",
100
+ }
101
+ runtime = mock.Mock()
102
+ runtime.project_config = BaseProjectConfig(UniversalConfig(), config={})
103
+ runtime.keychain = BaseProjectKeychain(runtime.project_config, None)
104
+ responses.add(
105
+ method="GET",
106
+ url="https://instance/services/oauth2/userinfo",
107
+ body=b"{}",
108
+ status=200,
109
+ )
110
+ responses.add(
111
+ method="GET",
112
+ url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
113
+ json={
114
+ "TrialExpirationDate": None,
115
+ "OrganizationType": "Developer Edition",
116
+ "IsSandbox": False,
117
+ "InstanceName": "CS420",
118
+ "NamespacePrefix": None,
119
+ },
120
+ status=200,
121
+ )
122
+ responses.add(
123
+ "GET",
124
+ "https://instance/services/data",
125
+ json=[{"version": CURRENT_SF_API_VERSION}],
126
+ )
127
+
128
+ result = run_cli_command("org", "connect", "test", "--default", runtime=runtime)
129
+
130
+ name, org_config = runtime.keychain.get_default_org()
131
+ assert name == "test"
132
+ assert org_config.id == "OODxxxxxxxxxxxx/user"
133
+ assert org_config.connected_app == "built-in"
134
+ assert org_config.expires == "Persistent"
135
+ assert "Connecting org using the built-in connected app..." in result.output
136
+ assert "test is now the default org" in result.output
137
+
138
+ @mock.patch("cumulusci.oauth.client.OAuth2Client.auth_code_flow")
139
+ @responses.activate
140
+ def test_org_connect__non_default_connected_app(self, auth_code_flow):
141
+ auth_code_flow.return_value = {
142
+ "instance_url": "https://instance",
143
+ "access_token": "BOGUS",
144
+ "id": "OODxxxxxxxxxxxx/user",
145
+ }
146
+ runtime = mock.Mock()
147
+ runtime.project_config = BaseProjectConfig(UniversalConfig(), config={})
148
+ runtime.keychain = BaseProjectKeychain(runtime.project_config, None)
149
+ runtime.keychain.set_service(
150
+ "connected_app",
151
+ "other",
152
+ ServiceConfig(
153
+ {
154
+ "login_url": "https://other",
155
+ "callback_url": "http://localhost:8080/callback",
156
+ "client_id": "ID",
157
+ "client_secret": "SECRET",
158
+ }
159
+ ),
160
+ )
161
+ responses.add(
162
+ method="GET",
163
+ url="https://instance/services/oauth2/userinfo",
164
+ body=b"{}",
165
+ status=200,
166
+ )
167
+ responses.add(
168
+ method="GET",
169
+ url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
170
+ json={
171
+ "TrialExpirationDate": None,
172
+ "OrganizationType": "Developer Edition",
173
+ "IsSandbox": False,
174
+ "InstanceName": "CS420",
175
+ "NamespacePrefix": None,
176
+ },
177
+ status=200,
178
+ )
179
+ responses.add(
180
+ "GET",
181
+ "https://instance/services/data",
182
+ json=[{"version": CURRENT_SF_API_VERSION}],
183
+ )
184
+
185
+ result = run_cli_command(
186
+ "org", "connect", "test", "--connected_app", "other", runtime=runtime
187
+ )
188
+
189
+ org_config = runtime.keychain.get_org("test")
190
+ assert org_config.connected_app == "other"
191
+ assert "Connecting org using the other connected app..." in result.output
192
+
193
+ @mock.patch("cumulusci.cli.org.connect_org_to_keychain")
194
+ def test_org_connect__sandbox(self, connect_to_keychain):
195
+ mocked_connected_app = mock.Mock()
196
+ mocked_connected_app.client_id = "foo"
197
+ mocked_connected_app.client_secret = "bar"
198
+ mocked_connected_app.callback_url = "https://foo.bar.baz/"
199
+
200
+ runtime = mock.Mock()
201
+ runtime.keychain.get_service.return_value = mocked_connected_app
202
+
203
+ run_cli_command("org", "connect", "blah", "--sandbox", runtime=runtime)
204
+
205
+ actual_client_config = connect_to_keychain.call_args_list[0][0][0].client_config
206
+ assert actual_client_config.auth_uri.startswith("https://test.salesforce.com/")
207
+ assert actual_client_config.token_uri.startswith("https://test.salesforce.com/")
208
+
209
+ @mock.patch("cumulusci.cli.org.connect_org_to_keychain")
210
+ def test_org_connect__prod_default(self, connect_to_keychain):
211
+ runtime = mock.Mock()
212
+ runtime.project_config = BaseProjectConfig(UniversalConfig(), config={})
213
+ runtime.keychain = BaseProjectKeychain(runtime.project_config, None)
214
+
215
+ run_cli_command("org", "connect", "blah", runtime=runtime)
216
+
217
+ actual_client_config = connect_to_keychain.call_args_list[0][0][0].client_config
218
+ assert actual_client_config.auth_uri.startswith("https://login.salesforce.com/")
219
+ assert actual_client_config.token_uri.startswith(
220
+ "https://login.salesforce.com/"
221
+ )
222
+
223
+ @mock.patch("cumulusci.cli.org.connect_org_to_keychain")
224
+ def test_org_connect__other_connected_app_login_url(self, connect_to_keychain):
225
+ runtime = mock.Mock()
226
+ runtime.project_config = BaseProjectConfig(UniversalConfig(), config={})
227
+ runtime.keychain = BaseProjectKeychain(runtime.project_config, None)
228
+ runtime.keychain.set_service(
229
+ "connected_app",
230
+ "other",
231
+ ServiceConfig(
232
+ {
233
+ "client_id": "foo",
234
+ "client_secret": "bar",
235
+ "callback_url": "https://foo.bar.baz/",
236
+ "login_url": "https://other",
237
+ }
238
+ ),
239
+ )
240
+
241
+ run_cli_command(
242
+ "org", "connect", "blah", "--connected-app", "other", runtime=runtime
243
+ )
244
+
245
+ actual_client_config = connect_to_keychain.call_args_list[0][0][0].client_config
246
+ assert actual_client_config.auth_uri.startswith("https://other/")
247
+ assert actual_client_config.token_uri.startswith("https://other/")
248
+
249
+ @mock.patch("cumulusci.cli.org.connect_org_to_keychain")
250
+ def test_org_connect__login_url_from_cli_option(self, connect_to_keychain):
251
+ runtime = mock.Mock()
252
+ runtime.project_config = BaseProjectConfig(UniversalConfig(), config={})
253
+ runtime.keychain = BaseProjectKeychain(runtime.project_config, None)
254
+
255
+ run_cli_command(
256
+ "org", "connect", "blah", "--login-url", "https://custom", runtime=runtime
257
+ )
258
+
259
+ actual_client_config = connect_to_keychain.call_args_list[0][0][0].client_config
260
+ assert actual_client_config.auth_uri.startswith("https://custom/")
261
+ assert actual_client_config.token_uri.startswith("https://custom/")
262
+
263
+ def test_org_connect__bad_connected_app_name(self):
264
+ runtime = mock.Mock()
265
+ runtime.project_config = BaseProjectConfig(UniversalConfig(), config={})
266
+ runtime.keychain = BaseProjectKeychain(runtime.project_config, None)
267
+
268
+ with pytest.raises(
269
+ ServiceNotConfigured,
270
+ match="No service of type connected_app configured with name: bogus",
271
+ ):
272
+ run_cli_command(
273
+ "org", "connect", "blah", "--connected-app", "bogus", runtime=runtime
274
+ )
275
+
276
+ @mock.patch("cumulusci.cli.org.OAuth2Client")
277
+ @responses.activate
278
+ def test_org_connect_expires(self, oauth2client):
279
+ client_instance = mock.Mock()
280
+ client_instance.auth_code_flow.return_value = {
281
+ "instance_url": "https://instance",
282
+ "access_token": "BOGUS",
283
+ "id": "OODxxxxxxxxxxxx/user",
284
+ }
285
+ oauth2client.return_value = client_instance
286
+ runtime = mock.Mock()
287
+ runtime.keychain.get_service.return_value = mock.Mock(
288
+ client_id="asdfasdf",
289
+ client_secret="asdfasdf",
290
+ callback_url="http://localhost:8080/callback",
291
+ )
292
+ responses.add(
293
+ method="GET",
294
+ url="https://instance/services/oauth2/userinfo",
295
+ body=b"{}",
296
+ status=200,
297
+ )
298
+ responses.add(
299
+ method="GET",
300
+ url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
301
+ json={
302
+ "TrialExpirationDate": "1970-01-01T12:34:56.000+0000",
303
+ "OrganizationType": "Developer Edition",
304
+ "IsSandbox": True,
305
+ "InstanceName": "CS420",
306
+ "NamespacePrefix": None,
307
+ },
308
+ status=200,
309
+ )
310
+ responses.add(
311
+ "GET",
312
+ "https://instance/services/data",
313
+ json=[{"version": CURRENT_SF_API_VERSION}],
314
+ )
315
+
316
+ run_click_command(
317
+ org.org_connect,
318
+ runtime=runtime,
319
+ org_name="test",
320
+ sandbox=True,
321
+ login_url=None,
322
+ default=True,
323
+ global_org=False,
324
+ )
325
+
326
+ runtime.check_org_overwrite.assert_called_once()
327
+ runtime.keychain.set_org.assert_called_once()
328
+ org_config = runtime.keychain.set_org.call_args[0][0]
329
+ assert org_config.expires == date(1970, 1, 1)
330
+ runtime.keychain.set_default_org.assert_called_once_with("test")
331
+
332
+ def test_org_connect_connected_app_not_configured(self):
333
+ runtime = mock.Mock()
334
+ runtime.keychain.get_service.side_effect = ServiceNotConfigured
335
+
336
+ with pytest.raises(ServiceNotConfigured):
337
+ run_click_command(
338
+ org.org_connect,
339
+ runtime=runtime,
340
+ org_name="test",
341
+ sandbox=True,
342
+ login_url=None,
343
+ default=True,
344
+ global_org=False,
345
+ )
346
+
347
+ def test_org_connect_lightning_url(self):
348
+ runtime = mock.Mock()
349
+
350
+ with pytest.raises(click.UsageError, match="lightning"):
351
+ run_click_command(
352
+ org.org_connect,
353
+ runtime=runtime,
354
+ org_name="test",
355
+ sandbox=True,
356
+ login_url="https://test1.lightning.force.com/",
357
+ default=True,
358
+ global_org=False,
359
+ )
360
+
361
+ def test_org_default(self):
362
+ runtime = mock.Mock()
363
+
364
+ run_click_command(
365
+ org.org_default, runtime=runtime, org_name="test", unset=False
366
+ )
367
+
368
+ runtime.keychain.set_default_org.assert_called_once_with("test")
369
+
370
+ def test_org_default_unset(self):
371
+ runtime = mock.Mock()
372
+
373
+ run_click_command(org.org_default, runtime=runtime, org_name="test", unset=True)
374
+
375
+ runtime.keychain.unset_default_org.assert_called_once()
376
+
377
+ @mock.patch("sarge.Command")
378
+ def test_org_import(self, cmd):
379
+ runtime = mock.Mock()
380
+ result = b"""{
381
+ "result": {
382
+ "createdDate": "1970-01-01T00:00:00.000Z",
383
+ "expirationDate": "1970-01-01",
384
+ "instanceUrl": "url",
385
+ "accessToken": "OODxxxxxxxxxxxx!token",
386
+ "username": "test@test.org",
387
+ "password": "password"
388
+ }
389
+ }"""
390
+ cmd.return_value = mock.Mock(
391
+ stderr=io.BytesIO(b""), stdout=io.BytesIO(result), returncode=0
392
+ )
393
+
394
+ out = []
395
+ with mock.patch("click.echo", out.append):
396
+ run_click_command(
397
+ org.org_import,
398
+ username_or_alias="test@test.org",
399
+ org_name="test",
400
+ runtime=runtime,
401
+ )
402
+ runtime.keychain.set_org.assert_called_once()
403
+ assert (
404
+ "Imported scratch org: OODxxxxxxxxxxxx, username: test@test.org"
405
+ in "".join(out)
406
+ )
407
+
408
+ @mock.patch("sarge.Command")
409
+ @responses.activate
410
+ def test_org_import__persistent_org(self, cmd):
411
+ runtime = mock.Mock()
412
+ result = b"""{
413
+ "result": {
414
+ "id": "OODxxxxxxxxxxxx",
415
+ "createdDate": null,
416
+ "instanceUrl": "https://instance",
417
+ "accessToken": "OODxxxxxxxxxxxx!token",
418
+ "username": "test@test.org",
419
+ "password": "password"
420
+ }
421
+ }"""
422
+ cmd.return_value = mock.Mock(
423
+ stderr=io.BytesIO(b""), stdout=io.BytesIO(result), returncode=0
424
+ )
425
+
426
+ # Mock the call to get the Organization sObject
427
+ responses.add(
428
+ method="GET",
429
+ url="https://instance/services/data",
430
+ status=200,
431
+ json=[{"version": CURRENT_SF_API_VERSION}],
432
+ )
433
+ responses.add(
434
+ method="GET",
435
+ url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
436
+ json={
437
+ "TrialExpirationDate": None,
438
+ "OrganizationType": "Developer Edition",
439
+ "IsSandbox": True,
440
+ "InstanceName": "CS420",
441
+ "NamespacePrefix": None,
442
+ },
443
+ status=200,
444
+ )
445
+
446
+ out = []
447
+ with mock.patch("click.echo", out.append):
448
+ run_click_command(
449
+ org.org_import,
450
+ username_or_alias="test@test.org",
451
+ org_name="test",
452
+ runtime=runtime,
453
+ )
454
+ runtime.keychain.set_org.assert_called_once()
455
+ created_org = runtime.keychain.set_org.call_args[0][0]
456
+ assert isinstance(created_org, SfdxOrgConfig)
457
+ assert created_org.config["sfdx"]
458
+ assert created_org.config["expires"] == "Persistent"
459
+
460
+ assert "Imported org: OODxxxxxxxxxxxx, username: test@test.org" in "".join(out)
461
+
462
+ @mock.patch("sarge.Command")
463
+ @responses.activate
464
+ def test_org_import__trial_org(self, cmd):
465
+ runtime = mock.Mock()
466
+ result = b"""{
467
+ "result": {
468
+ "id": "OODxxxxxxxxxxxx",
469
+ "createdDate": null,
470
+ "instanceUrl": "https://instance",
471
+ "accessToken": "OODxxxxxxxxxxxx!token",
472
+ "username": "test@test.org",
473
+ "password": "password"
474
+ }
475
+ }"""
476
+ cmd.return_value = mock.Mock(
477
+ stderr=io.BytesIO(b""), stdout=io.BytesIO(result), returncode=0
478
+ )
479
+
480
+ # Mock the call to get the Organization sObject
481
+ api_datetime = "2030-08-07T16:00:56.000+0000"
482
+ responses.add(
483
+ method="GET",
484
+ url="https://instance/services/data",
485
+ status=200,
486
+ json=[{"version": CURRENT_SF_API_VERSION}],
487
+ )
488
+ responses.add(
489
+ method="GET",
490
+ url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
491
+ json={
492
+ "TrialExpirationDate": api_datetime,
493
+ "OrganizationType": "Developer Edition",
494
+ "IsSandbox": True,
495
+ "InstanceName": "CS420",
496
+ "NamespacePrefix": None,
497
+ },
498
+ status=200,
499
+ )
500
+
501
+ out = []
502
+ with mock.patch("click.echo", out.append):
503
+ run_click_command(
504
+ org.org_import,
505
+ username_or_alias="test@test.org",
506
+ org_name="test",
507
+ runtime=runtime,
508
+ )
509
+ runtime.keychain.set_org.assert_called_once()
510
+ created_org = runtime.keychain.set_org.call_args[0][0]
511
+ assert isinstance(created_org, SfdxOrgConfig)
512
+ assert created_org.config["sfdx"]
513
+ assert (
514
+ created_org.config["expires"] == parse_api_datetime(api_datetime).date()
515
+ )
516
+
517
+ assert "Imported org: OODxxxxxxxxxxxx, username: test@test.org" in "".join(out)
518
+
519
+ def test_calculate_org_days(self):
520
+ info_1 = {
521
+ "created_date": "1970-01-01T12:34:56.789Z",
522
+ "expiration_date": "1970-01-02",
523
+ }
524
+ actual_days = org.calculate_org_days(info_1)
525
+ assert 1 == actual_days
526
+
527
+ info_7 = {
528
+ "created_date": "1970-01-01T12:34:56.789+0000",
529
+ "expiration_date": "1970-01-08",
530
+ }
531
+ actual_days = org.calculate_org_days(info_7)
532
+ assert 7 == actual_days
533
+
534
+ info_14 = {
535
+ "created_date": "1970-01-01T12:34:56.000+0000",
536
+ "expiration_date": "1970-01-15",
537
+ }
538
+ actual_days = org.calculate_org_days(info_14)
539
+ assert 14 == actual_days
540
+
541
+ info_bad__no_created_date = {"expiration_date": "1970-01-15"}
542
+ actual_days = org.calculate_org_days(info_bad__no_created_date)
543
+ assert 1 == actual_days
544
+
545
+ info_bad__no_expiration_date = {"created_date": "1970-01-01T12:34:56.000+0000"}
546
+ actual_days = org.calculate_org_days(info_bad__no_expiration_date)
547
+ assert 1 == actual_days
548
+
549
+ def test_org_info(self):
550
+ org_config = mock.Mock()
551
+ org_config.config = {
552
+ "days": 1,
553
+ "default": True,
554
+ "password": None,
555
+ "connected_app": "built-in",
556
+ "namespace": "test",
557
+ }
558
+ org_config.expires = date.today()
559
+ org_config.latest_api_version = "42.0"
560
+ runtime = mock.Mock()
561
+ runtime.get_org.return_value = ("test", org_config)
562
+
563
+ with mock.patch("cumulusci.cli.org.CliTable") as cli_tbl:
564
+ run_click_command(
565
+ org.org_info, runtime=runtime, org_name="test", print_json=False
566
+ )
567
+ cli_tbl.assert_called_with(
568
+ [
569
+ ["Org: test", ""],
570
+ ["\x1b[1mapi_version\x1b[0m", "42.0"],
571
+ ["\x1b[1mconnected_app\x1b[0m", "built-in"],
572
+ ["\x1b[1mdays\x1b[0m", "1"],
573
+ ["\x1b[1mdefault\x1b[0m", "True"],
574
+ ["\x1b[1mnamespace\x1b[0m", "test"],
575
+ ["\x1b[1mpassword\x1b[0m", "None"],
576
+ ],
577
+ )
578
+
579
+ org_config.save.assert_called_once_with()
580
+
581
+ def test_org_info_json(self, capsys):
582
+ class Unserializable(object):
583
+ def __str__(self):
584
+ return "<unserializable>"
585
+
586
+ org_config = mock.Mock()
587
+ org_config.config = {"test": "test", "unserializable": Unserializable()}
588
+ org_config.expires = date.today()
589
+ runtime = mock.Mock()
590
+ runtime.get_org.return_value = ("test", org_config)
591
+
592
+ run_click_command(
593
+ org.org_info, runtime=runtime, org_name="test", print_json=True
594
+ )
595
+
596
+ org_config.refresh_oauth_token.assert_called_once()
597
+ captured = capsys.readouterr()
598
+ assert (
599
+ captured.out
600
+ == '{\n "test": "test",\n "unserializable": "<unserializable>"\n}\n'
601
+ )
602
+ org_config.save.assert_called_once_with()
603
+
604
+ @mock.patch("cumulusci.cli.org.CliTable")
605
+ def test_org_list(self, cli_tbl):
606
+ runtime = mock.Mock()
607
+ runtime.universal_config.cli__plain_output = None
608
+ org_configs = {
609
+ "test0": ScratchOrgConfig(
610
+ {
611
+ "default": True,
612
+ "scratch": True,
613
+ "date_created": datetime.now() - timedelta(days=8),
614
+ "days": 7,
615
+ "config_name": "dev",
616
+ "username": "test0@example.com",
617
+ },
618
+ "test0",
619
+ ),
620
+ "test1": ScratchOrgConfig(
621
+ {
622
+ "default": False,
623
+ "scratch": True,
624
+ "date_created": datetime.now(),
625
+ "days": 7,
626
+ "config_name": "dev",
627
+ "username": "test1@example.com",
628
+ "instance_url": "https://sneaky-master-2330-dev-ed.cs22.my.salesforce.com",
629
+ },
630
+ "test1",
631
+ ),
632
+ "test2": OrgConfig(
633
+ {
634
+ "default": False,
635
+ "scratch": False,
636
+ "expires": "Persistent",
637
+ "expired": False,
638
+ "config_name": "dev",
639
+ "username": "test2@example.com",
640
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
641
+ },
642
+ "test2",
643
+ ),
644
+ "test3": OrgConfig(
645
+ {
646
+ "default": False,
647
+ "scratch": False,
648
+ "expires": "2019-11-19",
649
+ "expired": False,
650
+ "config_name": "dev",
651
+ "username": "test3@example.com",
652
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
653
+ },
654
+ "test3",
655
+ ),
656
+ "test4": OrgConfig(
657
+ {
658
+ "default": False,
659
+ "scratch": False,
660
+ "expired": False,
661
+ "config_name": "dev",
662
+ "username": "test4@example.com",
663
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
664
+ },
665
+ "test4",
666
+ ),
667
+ "test5": OrgConfig(
668
+ {
669
+ "default": False,
670
+ "scratch": True,
671
+ "expires": "2019-11-19",
672
+ "expired": False,
673
+ "config_name": "dev",
674
+ "username": "test5@example.com",
675
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
676
+ },
677
+ "test5",
678
+ ),
679
+ "test6": OrgConfig(
680
+ {
681
+ "default": False,
682
+ "scratch": True,
683
+ "expired": False,
684
+ "config_name": "dev",
685
+ "username": "test6@example.com",
686
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
687
+ },
688
+ "test6",
689
+ ),
690
+ }
691
+
692
+ runtime.keychain.list_orgs.return_value = list(org_configs.keys())
693
+ runtime.keychain.get_org = lambda orgname: org_configs[orgname]
694
+ runtime.project_config.cache_dir = Path("does_not_possibly_exist")
695
+
696
+ runtime.keychain.get_default_org.return_value = (
697
+ "test0",
698
+ ScratchOrgConfig(
699
+ {
700
+ "default": True,
701
+ "scratch": True,
702
+ "date_created": datetime.now() - timedelta(days=8),
703
+ "days": 7,
704
+ "config_name": "dev",
705
+ "username": "test0@example.com",
706
+ },
707
+ "test0",
708
+ ),
709
+ )
710
+
711
+ run_click_command(org.org_list, runtime=runtime, json_flag=False, plain=False)
712
+
713
+ scratch_table_call = mock.call(
714
+ [
715
+ ["Default", "Name", "Days", "Expired", "Config", "Domain"],
716
+ [True, "test0", "7", True, "dev", ""],
717
+ [False, "test1", "1/7", False, "dev", "sneaky-master-2330-dev-ed.cs22"],
718
+ ],
719
+ title="Scratch Orgs",
720
+ dim_rows=[0, 1],
721
+ )
722
+ connected_table_call = mock.call(
723
+ [
724
+ ["Default", "Name", "Username", "Expires"],
725
+ [False, "test2", "test2@example.com", "Persistent"],
726
+ [False, "test3", "test3@example.com", "2019-11-19"],
727
+ [False, "test4", "test4@example.com", "Unknown"],
728
+ [False, "test5", "test5@example.com", "2019-11-19"],
729
+ [False, "test6", "test6@example.com", "Unknown"],
730
+ ],
731
+ title="Connected Orgs",
732
+ )
733
+
734
+ assert scratch_table_call in cli_tbl.call_args_list
735
+ assert connected_table_call in cli_tbl.call_args_list
736
+ runtime.keychain.cleanup_org_cache_dirs.assert_called_once()
737
+
738
+ @mock.patch("cumulusci.cli.org.click.echo")
739
+ def test_org_list__json(self, echo):
740
+ runtime = mock.Mock()
741
+ runtime.universal_config.cli__plain_output = None
742
+ org_configs = {
743
+ "test0": ScratchOrgConfig(
744
+ {
745
+ "default": True,
746
+ "scratch": True,
747
+ "date_created": datetime.now() - timedelta(days=8),
748
+ "days": 7,
749
+ "config_name": "dev",
750
+ "username": "test0@example.com",
751
+ },
752
+ "test0",
753
+ ),
754
+ "test1": ScratchOrgConfig(
755
+ {
756
+ "default": False,
757
+ "scratch": True,
758
+ "date_created": datetime.now(),
759
+ "days": 7,
760
+ "config_name": "dev",
761
+ "username": "test1@example.com",
762
+ "instance_url": "https://sneaky-master-2330-dev-ed.cs22.my.salesforce.com",
763
+ },
764
+ "test1",
765
+ ),
766
+ "test2": OrgConfig(
767
+ {
768
+ "default": False,
769
+ "scratch": False,
770
+ "expires": "Persistent",
771
+ "expired": False,
772
+ "config_name": "dev",
773
+ "username": "test2@example.com",
774
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
775
+ },
776
+ "test2",
777
+ ),
778
+ }
779
+
780
+ runtime.keychain.list_orgs.return_value = list(org_configs.keys())
781
+ runtime.keychain.get_org = lambda orgname: org_configs[orgname]
782
+ runtime.project_config.cache_dir = Path("does_not_possibly_exist")
783
+
784
+ runtime.keychain.get_default_org.return_value = (
785
+ "test0",
786
+ ScratchOrgConfig(
787
+ {
788
+ "default": True,
789
+ "scratch": True,
790
+ "date_created": datetime.now() - timedelta(days=8),
791
+ "days": 7,
792
+ "config_name": "dev",
793
+ "username": "test0@example.com",
794
+ },
795
+ "test0",
796
+ ),
797
+ )
798
+
799
+ run_click_command(org.org_list, runtime=runtime, json_flag=True, plain=False)
800
+ expected = {
801
+ "test0": {
802
+ "is_default": True,
803
+ "name": "test0",
804
+ "days": "7",
805
+ "expired": True,
806
+ "config": "dev",
807
+ "domain": "",
808
+ "is_scratch": True,
809
+ },
810
+ "test1": {
811
+ "is_default": False,
812
+ "name": "test1",
813
+ "days": "1/7",
814
+ "expired": False,
815
+ "config": "dev",
816
+ "domain": "sneaky-master-2330-dev-ed.cs22",
817
+ "is_scratch": True,
818
+ },
819
+ "test2": {
820
+ "is_default": False,
821
+ "name": "test2",
822
+ "username": "test2@example.com",
823
+ "expires": "Persistent",
824
+ "is_scratch": False,
825
+ },
826
+ }
827
+
828
+ echo.assert_called_once_with(json.dumps(expected))
829
+
830
+ @mock.patch("click.echo")
831
+ @mock.patch("cumulusci.cli.org.CliTable")
832
+ def test_org_list__error(self, cli_tbl, echo):
833
+ runtime = mock.Mock()
834
+ runtime.universal_config.cli__plain_output = None
835
+ org_configs = {
836
+ "test0": ScratchOrgConfig(
837
+ {
838
+ "default": True,
839
+ "scratch": True,
840
+ "date_created": datetime.now() - timedelta(days=8),
841
+ "days": 7,
842
+ "config_name": "dev",
843
+ "username": "test0@example.com",
844
+ },
845
+ "test0",
846
+ ),
847
+ "test1": AssertionError("NOPE!"),
848
+ "test2": OrgConfig(
849
+ {
850
+ "default": False,
851
+ "scratch": False,
852
+ "expires": "Persistent",
853
+ "expired": False,
854
+ "config_name": "dev",
855
+ "username": "test2@example.com",
856
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
857
+ },
858
+ "test2",
859
+ ),
860
+ }
861
+
862
+ runtime.keychain.list_orgs.return_value = list(org_configs.keys())
863
+
864
+ def get_org(orgname):
865
+ value = org_configs[orgname]
866
+ if isinstance(value, Exception):
867
+ raise value
868
+ return value
869
+
870
+ runtime.keychain.get_org = get_org
871
+ runtime.project_config.cache_dir = Path("does_not_possibly_exist")
872
+ runtime.keychain.cleanup_org_cache_dirs.side_effect = AssertionError("OUCH!")
873
+
874
+ runtime.keychain.get_default_org.return_value = (
875
+ "test0",
876
+ ScratchOrgConfig(
877
+ {
878
+ "default": True,
879
+ "scratch": True,
880
+ "date_created": datetime.now() - timedelta(days=8),
881
+ "days": 7,
882
+ "config_name": "dev",
883
+ "username": "test0@example.com",
884
+ },
885
+ "test0",
886
+ ),
887
+ )
888
+
889
+ run_click_command(org.org_list, runtime=runtime, json_flag=False, plain=False)
890
+
891
+ assert "Cannot load org config for `test1`" in str(
892
+ echo.mock_calls
893
+ ), echo.mock_calls
894
+ assert "NOPE!" in str(echo.mock_calls), echo.mock_calls
895
+ assert "Cannot cleanup org cache dirs" in str(echo.mock_calls), echo.mock_calls
896
+
897
+ @mock.patch("click.echo")
898
+ def test_org_prune(self, echo):
899
+ runtime = mock.Mock()
900
+ runtime.keychain.list_orgs.return_value = [
901
+ "shape1",
902
+ "shape2",
903
+ "remove1",
904
+ "remove2",
905
+ "active1",
906
+ "active2",
907
+ "persistent",
908
+ ]
909
+
910
+ runtime.project_config.lookup = MockLookup(
911
+ orgs__scratch={
912
+ "shape1": True,
913
+ "shape2": True,
914
+ },
915
+ )
916
+
917
+ runtime.keychain.get_org.side_effect = [
918
+ ScratchOrgConfig(
919
+ {
920
+ "default": True,
921
+ "scratch": True,
922
+ "date_created": datetime.now() - timedelta(days=8),
923
+ "days": 7,
924
+ "config_name": "dev",
925
+ "username": "test0@example.com",
926
+ },
927
+ "shape1",
928
+ ),
929
+ ScratchOrgConfig(
930
+ {
931
+ "default": False,
932
+ "scratch": True,
933
+ "date_created": datetime.now(),
934
+ "days": 7,
935
+ "config_name": "dev",
936
+ "username": "test1@example.com",
937
+ },
938
+ "shape2",
939
+ ),
940
+ ScratchOrgConfig(
941
+ {
942
+ "default": False,
943
+ "scratch": True,
944
+ "date_created": datetime(1999, 11, 1),
945
+ "days": 7,
946
+ "config_name": "dev",
947
+ "username": "remove1@example.com",
948
+ },
949
+ "remove1",
950
+ ),
951
+ ScratchOrgConfig(
952
+ {
953
+ "default": False,
954
+ "scratch": True,
955
+ "date_created": datetime(1999, 11, 1),
956
+ "days": 7,
957
+ "config_name": "dev",
958
+ "username": "remove2@example.com",
959
+ },
960
+ "remove2",
961
+ ),
962
+ ScratchOrgConfig(
963
+ {
964
+ "default": False,
965
+ "scratch": True,
966
+ "date_created": datetime.now() - timedelta(days=1),
967
+ "days": 7,
968
+ "config_name": "dev",
969
+ "username": "active1@example.com",
970
+ },
971
+ "active1",
972
+ ),
973
+ ScratchOrgConfig(
974
+ {
975
+ "default": False,
976
+ "scratch": True,
977
+ "date_created": datetime.now() - timedelta(days=1),
978
+ "days": 7,
979
+ "config_name": "dev",
980
+ "username": "active2@example.com",
981
+ },
982
+ "active2",
983
+ ),
984
+ OrgConfig(
985
+ {
986
+ "default": False,
987
+ "scratch": False,
988
+ "expires": "Persistent",
989
+ "expired": False,
990
+ "config_name": "dev",
991
+ "username": "persistent@example.com",
992
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
993
+ },
994
+ "persistent",
995
+ ),
996
+ ]
997
+
998
+ run_click_command(org.org_prune, runtime=runtime, include_active=False)
999
+
1000
+ echo.assert_any_call(
1001
+ "Successfully removed 2 expired scratch orgs: remove1, remove2"
1002
+ )
1003
+ echo.assert_any_call("Skipped org shapes: shape1, shape2")
1004
+ echo.assert_any_call("Skipped active orgs: active1, active2")
1005
+
1006
+ runtime.keychain.remove_org.assert_has_calls(
1007
+ [mock.call("remove1"), mock.call("remove2")]
1008
+ )
1009
+ assert runtime.keychain.remove_org.call_count == 2
1010
+
1011
+ @mock.patch("click.echo")
1012
+ def test_org_prune_no_expired(self, echo):
1013
+ runtime = mock.Mock()
1014
+ runtime.keychain.list_orgs.return_value = [
1015
+ "shape1",
1016
+ "shape2",
1017
+ "active1",
1018
+ "active2",
1019
+ "persistent",
1020
+ ]
1021
+
1022
+ runtime.project_config.lookup = MockLookup(
1023
+ orgs__scratch={
1024
+ "shape1": True,
1025
+ "shape2": True,
1026
+ }
1027
+ )
1028
+
1029
+ runtime.keychain.get_org.side_effect = [
1030
+ ScratchOrgConfig(
1031
+ {
1032
+ "default": True,
1033
+ "scratch": True,
1034
+ "date_created": datetime.now() - timedelta(days=8),
1035
+ "days": 7,
1036
+ "config_name": "dev",
1037
+ "username": "test0@example.com",
1038
+ },
1039
+ "shape1",
1040
+ ),
1041
+ ScratchOrgConfig(
1042
+ {
1043
+ "default": False,
1044
+ "scratch": True,
1045
+ "date_created": datetime.now(),
1046
+ "days": 7,
1047
+ "config_name": "dev",
1048
+ "username": "test1@example.com",
1049
+ },
1050
+ "shape2",
1051
+ ),
1052
+ ScratchOrgConfig(
1053
+ {
1054
+ "default": False,
1055
+ "scratch": True,
1056
+ "date_created": datetime.now() - timedelta(days=1),
1057
+ "days": 7,
1058
+ "config_name": "dev",
1059
+ "username": "active1@example.com",
1060
+ },
1061
+ "active1",
1062
+ ),
1063
+ ScratchOrgConfig(
1064
+ {
1065
+ "default": False,
1066
+ "scratch": True,
1067
+ "date_created": datetime.now() - timedelta(days=1),
1068
+ "days": 7,
1069
+ "config_name": "dev",
1070
+ "username": "active2@example.com",
1071
+ },
1072
+ "active2",
1073
+ ),
1074
+ OrgConfig(
1075
+ {
1076
+ "default": False,
1077
+ "scratch": False,
1078
+ "expires": "Persistent",
1079
+ "expired": False,
1080
+ "config_name": "dev",
1081
+ "username": "persistent@example.com",
1082
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
1083
+ },
1084
+ "persistent",
1085
+ ),
1086
+ ]
1087
+
1088
+ run_click_command(org.org_prune, runtime=runtime, include_active=False)
1089
+ runtime.keychain.remove_org.assert_not_called()
1090
+
1091
+ echo.assert_any_call("No expired scratch orgs to delete. ✨")
1092
+
1093
+ @mock.patch("click.echo")
1094
+ def test_org_prune_include_active(self, echo):
1095
+ runtime = mock.Mock()
1096
+ runtime.keychain.list_orgs.return_value = [
1097
+ "shape1",
1098
+ "shape2",
1099
+ "remove1",
1100
+ "remove2",
1101
+ "active1",
1102
+ "active2",
1103
+ "persistent",
1104
+ ]
1105
+
1106
+ def lookup(name, default):
1107
+ assert name == "orgs__scratch", name
1108
+ return {"shape1": True, "shape2": True}
1109
+
1110
+ runtime.project_config.lookup = lookup
1111
+
1112
+ runtime.keychain.get_org.side_effect = [
1113
+ ScratchOrgConfig(
1114
+ {
1115
+ "default": True,
1116
+ "scratch": True,
1117
+ "days": 7,
1118
+ "config_name": "dev",
1119
+ "username": "test0@example.com",
1120
+ },
1121
+ "shape1",
1122
+ ),
1123
+ ScratchOrgConfig(
1124
+ {
1125
+ "default": False,
1126
+ "scratch": True,
1127
+ "days": 7,
1128
+ "config_name": "dev",
1129
+ "username": "test1@example.com",
1130
+ },
1131
+ "shape2",
1132
+ ),
1133
+ ScratchOrgConfig(
1134
+ {
1135
+ "default": False,
1136
+ "scratch": True,
1137
+ "date_created": datetime(1999, 11, 1),
1138
+ "days": 7,
1139
+ "config_name": "dev",
1140
+ "username": "remove1@example.com",
1141
+ },
1142
+ "remove1",
1143
+ ),
1144
+ ScratchOrgConfig(
1145
+ {
1146
+ "default": False,
1147
+ "scratch": True,
1148
+ "date_created": datetime(1999, 11, 1),
1149
+ "days": 7,
1150
+ "config_name": "dev",
1151
+ "username": "remove2@example.com",
1152
+ },
1153
+ "remove2",
1154
+ ),
1155
+ ScratchOrgConfig(
1156
+ {
1157
+ "default": False,
1158
+ "scratch": True,
1159
+ "date_created": datetime.now() - timedelta(days=1),
1160
+ "days": 7,
1161
+ "config_name": "dev",
1162
+ "username": "active1@example.com",
1163
+ },
1164
+ "active1",
1165
+ ),
1166
+ ScratchOrgConfig(
1167
+ {
1168
+ "default": False,
1169
+ "scratch": True,
1170
+ "date_created": datetime.now() - timedelta(days=1),
1171
+ "days": 7,
1172
+ "config_name": "dev",
1173
+ "username": "active2@example.com",
1174
+ },
1175
+ "active2",
1176
+ ),
1177
+ OrgConfig(
1178
+ {
1179
+ "default": False,
1180
+ "scratch": False,
1181
+ "expires": "Persistent",
1182
+ "expired": False,
1183
+ "config_name": "dev",
1184
+ "username": "persistent@example.com",
1185
+ "instance_url": "https://dude-chillin-2330-dev-ed.cs22.my.salesforce.com",
1186
+ },
1187
+ "persistent",
1188
+ ),
1189
+ ]
1190
+
1191
+ run_click_command(org.org_prune, runtime=runtime, include_active=True)
1192
+
1193
+ echo.assert_any_call(
1194
+ "Successfully removed 2 expired scratch orgs: remove1, remove2"
1195
+ )
1196
+ echo.assert_any_call(
1197
+ "Successfully removed 2 active scratch orgs: active1, active2"
1198
+ )
1199
+ echo.assert_any_call("Skipped org shapes: shape1, shape2")
1200
+
1201
+ runtime.keychain.remove_org.assert_has_calls(
1202
+ [
1203
+ mock.call("remove1"),
1204
+ mock.call("remove2"),
1205
+ mock.call("active1"),
1206
+ mock.call("active2"),
1207
+ ]
1208
+ )
1209
+ assert runtime.keychain.remove_org.call_count == 4
1210
+
1211
+ def test_org_remove(self):
1212
+ org_config = mock.Mock()
1213
+ org_config.can_delete.return_value = True
1214
+ runtime = mock.Mock()
1215
+ runtime.keychain.get_org.return_value = org_config
1216
+
1217
+ run_click_command(
1218
+ org.org_remove, runtime=runtime, org_name="test", global_org=False
1219
+ )
1220
+
1221
+ org_config.delete_org.assert_called_once()
1222
+ runtime.keychain.remove_org.assert_called_once_with("test", False)
1223
+
1224
+ @mock.patch("click.echo")
1225
+ def test_org_remove_delete_error(self, echo):
1226
+ org_config = mock.Mock()
1227
+ org_config.can_delete.return_value = True
1228
+ org_config.delete_org.side_effect = Exception
1229
+ runtime = mock.Mock()
1230
+ runtime.keychain.get_org.return_value = org_config
1231
+
1232
+ run_click_command(
1233
+ org.org_remove, runtime=runtime, org_name="test", global_org=False
1234
+ )
1235
+
1236
+ echo.assert_any_call("Removing org regardless.")
1237
+
1238
+ def test_org_remove_not_found(self):
1239
+ runtime = mock.Mock()
1240
+ runtime.keychain.get_org.side_effect = OrgNotFound
1241
+
1242
+ with pytest.raises(
1243
+ click.ClickException, match="Org test does not exist in the keychain"
1244
+ ):
1245
+ run_click_command(
1246
+ org.org_remove, runtime=runtime, org_name="test", global_org=False
1247
+ )
1248
+
1249
+ def test_org_scratch(self):
1250
+ runtime = mock.Mock()
1251
+
1252
+ runtime.project_config.lookup = MockLookup(
1253
+ orgs__scratch={"dev": {"orgName": "Dev"}}
1254
+ )
1255
+
1256
+ run_click_command(
1257
+ org.org_scratch,
1258
+ runtime=runtime,
1259
+ config_name="dev",
1260
+ org_name="test",
1261
+ default=True,
1262
+ devhub="hub",
1263
+ days=7,
1264
+ no_password=True,
1265
+ release="previous",
1266
+ )
1267
+
1268
+ runtime.check_org_overwrite.assert_called_once()
1269
+ runtime.keychain.create_scratch_org.assert_called_with(
1270
+ "test", "dev", 7, set_password=False, release="previous"
1271
+ )
1272
+ runtime.keychain.set_default_org.assert_called_with("test")
1273
+
1274
+ def test_org_scratch_release_invalid(self):
1275
+ runtime = mock.Mock()
1276
+
1277
+ runtime.project_config.lookup = MockLookup(
1278
+ orgs__scratch={"dev": {"orgName": "Dev"}}
1279
+ )
1280
+ with pytest.raises(click.UsageError):
1281
+ run_click_command(
1282
+ org.org_scratch,
1283
+ runtime=runtime,
1284
+ config_name="dev",
1285
+ org_name="test",
1286
+ default=True,
1287
+ devhub="hub",
1288
+ days=7,
1289
+ no_password=True,
1290
+ release="next",
1291
+ )
1292
+ runtime.check_org_overwrite.assert_called_once()
1293
+
1294
+ def test_org_scratch__not_default(self):
1295
+ runtime = mock.Mock()
1296
+ runtime.project_config.lookup = MockLookup(
1297
+ orgs__scratch={"dev": {"orgName": "Dev"}}
1298
+ )
1299
+ run_click_command(
1300
+ org.org_scratch,
1301
+ runtime=runtime,
1302
+ config_name="dev",
1303
+ org_name="test",
1304
+ default=False,
1305
+ devhub="hub",
1306
+ days=7,
1307
+ no_password=True,
1308
+ release=None,
1309
+ )
1310
+
1311
+ runtime.check_org_overwrite.assert_called_once()
1312
+ runtime.keychain.create_scratch_org.assert_called_with(
1313
+ "test", "dev", 7, set_password=False, release=None
1314
+ )
1315
+
1316
+ def test_org_scratch_no_configs(self):
1317
+ runtime = mock.Mock()
1318
+ runtime.project_config.lookup = MockLookup(orgs__scratch=None)
1319
+
1320
+ with pytest.raises(click.UsageError):
1321
+ run_click_command(
1322
+ org.org_scratch,
1323
+ runtime=runtime,
1324
+ config_name="dev",
1325
+ org_name="test",
1326
+ default=True,
1327
+ devhub="hub",
1328
+ days=7,
1329
+ no_password=True,
1330
+ release="previous",
1331
+ )
1332
+
1333
+ def test_org_scratch_config_not_found(self):
1334
+ runtime = mock.Mock()
1335
+ runtime.project_config.lookup = MockLookup(orgs__scratch={"bogus": {}})
1336
+
1337
+ with pytest.raises(click.UsageError):
1338
+ run_click_command(
1339
+ org.org_scratch,
1340
+ runtime=runtime,
1341
+ config_name="dev",
1342
+ org_name="test",
1343
+ default=True,
1344
+ devhub="hub",
1345
+ days=7,
1346
+ no_password=True,
1347
+ release="previous",
1348
+ )
1349
+
1350
+ def test_org_scratch_delete(self):
1351
+ org_config = mock.Mock()
1352
+ runtime = mock.Mock()
1353
+ runtime.keychain.get_org.return_value = org_config
1354
+
1355
+ run_click_command(org.org_scratch_delete, runtime=runtime, org_name="test")
1356
+
1357
+ org_config.delete_org.assert_called_once()
1358
+ org_config.save.assert_called_once_with()
1359
+
1360
+ def test_org_scratch_delete_not_scratch(self):
1361
+ org_config = mock.Mock(scratch=False)
1362
+ runtime = mock.Mock()
1363
+ runtime.keychain.get_org.return_value = org_config
1364
+
1365
+ with pytest.raises(click.UsageError):
1366
+ run_click_command(org.org_scratch_delete, runtime=runtime, org_name="test")
1367
+
1368
+ @mock.patch("click.echo")
1369
+ def test_org_scratch_delete_error(self, echo):
1370
+ org_config = mock.Mock()
1371
+ org_config.delete_org.side_effect = ScratchOrgException
1372
+ runtime = mock.Mock()
1373
+ runtime.keychain.get_org.return_value = org_config
1374
+ run_click_command(org.org_scratch_delete, runtime=runtime, org_name="test")
1375
+ assert "org remove" in str(echo.mock_calls)
1376
+
1377
+ @mock.patch("cumulusci.cli.org.get_simple_salesforce_connection")
1378
+ @mock.patch("code.interact")
1379
+ def test_org_shell(self, mock_code, mock_sf):
1380
+ org_config = mock.Mock()
1381
+ org_config.instance_url = "https://salesforce.com"
1382
+ org_config.access_token = "TEST"
1383
+ runtime = mock.Mock()
1384
+ runtime.get_org.return_value = ("test", org_config)
1385
+
1386
+ run_click_command(org.org_shell, runtime=runtime, org_name="test")
1387
+
1388
+ org_config.refresh_oauth_token.assert_called_once()
1389
+ mock_sf.assert_any_call(runtime.project_config, org_config)
1390
+ mock_sf.assert_any_call(runtime.project_config, org_config, base_url="tooling")
1391
+ org_config.save.assert_called_once_with()
1392
+
1393
+ mock_code.assert_called_once()
1394
+ assert "sf" in mock_code.call_args[1]["local"]
1395
+ assert "tooling" in mock_code.call_args[1]["local"]
1396
+
1397
+ @mock.patch("runpy.run_path")
1398
+ def test_org_shell_script(self, runpy):
1399
+ org_config = mock.Mock()
1400
+ org_config.instance_url = "https://salesforce.com"
1401
+ org_config.access_token = "TEST"
1402
+ runtime = mock.Mock()
1403
+ runtime.get_org.return_value = ("test", org_config)
1404
+ run_click_command(
1405
+ org.org_shell, runtime=runtime, org_name="test", script="foo.py"
1406
+ )
1407
+ runpy.assert_called_once()
1408
+ assert "sf" in runpy.call_args[1]["init_globals"]
1409
+ assert runpy.call_args[0][0] == "foo.py", runpy.call_args[0]
1410
+
1411
+ @mock.patch("cumulusci.cli.ui.SimpleSalesforceUIHelpers.describe")
1412
+ def test_org_shell_describe(self, describe):
1413
+ org_config = mock.Mock()
1414
+ org_config.instance_url = "https://salesforce.com"
1415
+ org_config.access_token = "TEST"
1416
+ runtime = mock.Mock()
1417
+ runtime.get_org.return_value = ("test", org_config)
1418
+ run_click_command(
1419
+ org.org_shell, runtime=runtime, org_name="test", python="describe('blah')"
1420
+ )
1421
+ describe.assert_called_once()
1422
+ assert "blah" in describe.call_args[0][0]
1423
+
1424
+ @mock.patch("cumulusci.cli.org.print")
1425
+ def test_org_shell_mutually_exclusive_args(self, print):
1426
+ org_config = mock.Mock()
1427
+ org_config.instance_url = "https://salesforce.com"
1428
+ org_config.access_token = "TEST"
1429
+ runtime = mock.Mock()
1430
+ runtime.get_org.return_value = ("test", org_config)
1431
+ with pytest.raises(Exception, match="Cannot specify both"):
1432
+ run_click_command(
1433
+ org.org_shell,
1434
+ runtime=runtime,
1435
+ org_name="foo",
1436
+ script="foo.py",
1437
+ python="print(config, runtime)",
1438
+ )