Skip to content

Commit

Permalink
Update default API version to v59.0 (#3680)
Browse files Browse the repository at this point in the history
This PR updates the default Salesforce API version to 59.0 and refactors
various tasks and tests to use the global default API version.

- Refactored CreatePackageVersion in create_package_version.py to use
dynamic API versioning. Fixes #3709
- Updated tasks that had previously been manually updated each release
(`github_package_data` and `activate_flow`) for dynamic API versioning.
- Revised tests across several files to use CURRENT_SF_API_VERSION from
cumulusci/tests/util.py.

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: James Estevez <jestevez@salesforce.com>
  • Loading branch information
3 people committed Dec 8, 2023
1 parent eec6886 commit 33bb241
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 84 deletions.
33 changes: 23 additions & 10 deletions cumulusci/cli/tests/test_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
)
from cumulusci.core.keychain import BaseProjectKeychain
from cumulusci.core.tests.utils import MockLookup
from cumulusci.tests.util import CURRENT_SF_API_VERSION
from cumulusci.utils import parse_api_datetime

from .. import org
Expand Down Expand Up @@ -108,7 +109,7 @@ def test_org_connect(self, auth_code_flow):
)
responses.add(
method="GET",
url="https://instance/services/data/v45.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": None,
"OrganizationType": "Developer Edition",
Expand All @@ -118,7 +119,11 @@ def test_org_connect(self, auth_code_flow):
},
status=200,
)
responses.add("GET", "https://instance/services/data", json=[{"version": 45.0}])
responses.add(
"GET",
"https://instance/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

result = run_cli_command("org", "connect", "test", "--default", runtime=runtime)

Expand Down Expand Up @@ -161,7 +166,7 @@ def test_org_connect__non_default_connected_app(self, auth_code_flow):
)
responses.add(
method="GET",
url="https://instance/services/data/v45.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": None,
"OrganizationType": "Developer Edition",
Expand All @@ -171,7 +176,11 @@ def test_org_connect__non_default_connected_app(self, auth_code_flow):
},
status=200,
)
responses.add("GET", "https://instance/services/data", json=[{"version": 45.0}])
responses.add(
"GET",
"https://instance/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

result = run_cli_command(
"org", "connect", "test", "--connected_app", "other", runtime=runtime
Expand Down Expand Up @@ -288,7 +297,7 @@ def test_org_connect_expires(self, oauth2client):
)
responses.add(
method="GET",
url="https://instance/services/data/v45.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": "1970-01-01T12:34:56.000+0000",
"OrganizationType": "Developer Edition",
Expand All @@ -298,7 +307,11 @@ def test_org_connect_expires(self, oauth2client):
},
status=200,
)
responses.add("GET", "https://instance/services/data", json=[{"version": 45.0}])
responses.add(
"GET",
"https://instance/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

run_click_command(
org.org_connect,
Expand Down Expand Up @@ -415,11 +428,11 @@ def test_org_import__persistent_org(self, cmd):
method="GET",
url="https://instance/services/data",
status=200,
json=[{"version": "54.0"}],
json=[{"version": CURRENT_SF_API_VERSION}],
)
responses.add(
method="GET",
url="https://instance/services/data/v54.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": None,
"OrganizationType": "Developer Edition",
Expand Down Expand Up @@ -470,11 +483,11 @@ def test_org_import__trial_org(self, cmd):
method="GET",
url="https://instance/services/data",
status=200,
json=[{"version": "54.0"}],
json=[{"version": CURRENT_SF_API_VERSION}],
)
responses.add(
method="GET",
url="https://instance/services/data/v54.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": api_datetime,
"OrganizationType": "Developer Edition",
Expand Down
78 changes: 52 additions & 26 deletions cumulusci/core/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
BaseProjectKeychain,
)
from cumulusci.core.source import LocalFolderSource
from cumulusci.tests.util import DummyKeychain
from cumulusci.tests.util import CURRENT_SF_API_VERSION, DummyKeychain
from cumulusci.utils import temporary_dir, touch
from cumulusci.utils.version_strings import StrictVersion
from cumulusci.utils.yaml.cumulusci_yml import GitHubSourceModel, LocalFolderSourceModel
Expand Down Expand Up @@ -1038,11 +1038,13 @@ def test_lightning_base_url__mydomain(self):
@responses.activate
def test_get_salesforce_version(self):
responses.add(
"GET", "https://na01.salesforce.com/services/data", json=[{"version": 42.0}]
"GET",
"https://na01.salesforce.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)
config = OrgConfig({"instance_url": "https://na01.salesforce.com"}, "test")
config.access_token = "TOKEN"
assert config.latest_api_version == "42.0"
assert config.latest_api_version == CURRENT_SF_API_VERSION

@responses.activate
def test_get_salesforce_version_bad_json(self):
Expand Down Expand Up @@ -1093,12 +1095,14 @@ def test_load_orginfo(self):
"test",
)
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/Organization/OODxxxxxxxxxxxx",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"OrganizationType": "Enterprise Edition",
"IsSandbox": False,
Expand Down Expand Up @@ -1129,11 +1133,15 @@ def test_get_community_info__fetch_if_not_in_cache(self):
The cache should be refreshed automatically if the requested community
is not in the cache.
"""
responses.add("GET", "https://test/services/data", json=[{"version": 48.0}])
responses.add(
"GET",
"https://test/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

responses.add(
"GET",
"https://test/services/data/v48.0/connect/communities",
f"https://test/services/data/v{CURRENT_SF_API_VERSION}/connect/communities",
json={"communities": [{"name": "Kōkua"}]},
)

Expand Down Expand Up @@ -1387,12 +1395,14 @@ def test_is_person_accounts_enabled__not_enabled(self):
), "_is_person_accounts_enabled should be initialized as None"

responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/Account/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Account/describe",
json={"fields": [{"name": "Id"}]},
)

Expand Down Expand Up @@ -1422,12 +1432,14 @@ def test_is_person_accounts_enabled__is_enabled(self):
), "_is_person_accounts_enabled should be initialized as None"

responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/Account/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Account/describe",
json={"fields": [{"name": "Id"}, {"name": "IsPersonAccount"}]},
)

Expand Down Expand Up @@ -1458,15 +1470,17 @@ def test_is_multi_currency_enabled__not_enabled(self):

# Login call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# CurrencyType describe() call.
# Since Multiple Currencies is not enabled, CurrencyType Sobject is not exposed.
# Therefore, the describe call will result in a 404.
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/CurrencyType/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/CurrencyType/describe",
status=404,
json={
"errorCode": "NOT_FOUND",
Expand All @@ -1477,7 +1491,7 @@ def test_is_multi_currency_enabled__not_enabled(self):
# Add a second 404 to demonstrate we always check the describe until we detect Multiple Currencies is enabled. From then on, we cache the fact that Multiple Currencies is enabled knowing Multiple Currencies cannot be disabled.
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/CurrencyType/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/CurrencyType/describe",
status=404,
json={
"errorCode": "NOT_FOUND",
Expand Down Expand Up @@ -1523,14 +1537,16 @@ def test_is_multi_currency_enabled__is_enabled(self):

# Token call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# CurrencyType describe() call.
# Since Multiple Currencies is enabled, so the describe call returns a 200.
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/CurrencyType/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/CurrencyType/describe",
json={
# The actual payload doesn't matter; only matters is we get a 200.
},
Expand Down Expand Up @@ -1572,15 +1588,17 @@ def test_is_advanced_currency_management_enabled__multiple_currencies_not_enable

# Token call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# DatedConversionRate describe() call.
# Since Multiple Currencies is not enabled, DatedConversionRate Sobject is not exposed.
# Therefore, the describe call will result in a 404.
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/DatedConversionRate/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/DatedConversionRate/describe",
status=404,
json={
"errorCode": "NOT_FOUND",
Expand Down Expand Up @@ -1613,15 +1631,17 @@ def test_is_advanced_currency_management_enabled__multiple_currencies_enabled__a

# Token call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# DatedConversionRate describe() call.
# Since Multiple Currencies is enabled, so the describe call returns a 200.
# However, ACM is not enabled so DatedConversionRate is not createable.
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/DatedConversionRate/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/DatedConversionRate/describe",
json={"createable": False},
)

Expand Down Expand Up @@ -1651,15 +1671,17 @@ def test_is_advanced_currency_management_enabled__multiple_currencies_enabled__a

# Token call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# DatedConversionRate describe() call.
# Since Multiple Currencies is enabled, so the describe call returns a 200.
# However, ACM is not enabled so DatedConversionRate is not createable.
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/DatedConversionRate/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/DatedConversionRate/describe",
json={"createable": True},
)

Expand Down Expand Up @@ -1687,13 +1709,15 @@ def test_is_survey_advanced_features_enabled(self):

# Token call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# describe()
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/PermissionSet/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/PermissionSet/describe",
json={"fields": [{"name": "PermissionsAllowSurveyAdvancedFeatures"}]},
)

Expand All @@ -1712,13 +1736,15 @@ def test_is_survey_advanced_features_enabled__not_enabled(self):

# Token call.
responses.add(
"GET", "https://example.com/services/data", json=[{"version": 48.0}]
"GET",
"https://example.com/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

# describe()
responses.add(
"GET",
"https://example.com/services/data/v48.0/sobjects/PermissionSet/describe",
f"https://example.com/services/data/v{CURRENT_SF_API_VERSION}/sobjects/PermissionSet/describe",
json={"fields": [{"name": "foo"}]},
)

Expand Down
3 changes: 1 addition & 2 deletions cumulusci/cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ tasks:
class_path: cumulusci.tasks.salesforce.activate_flow.ActivateFlow
options:
status: True

deactivate_flow:
group: Metadata Transformations
description: deactivates Flows identified by a given list of Developer Names
Expand Down Expand Up @@ -1466,7 +1465,7 @@ project:
namespace:
install_class:
uninstall_class:
api_version: "55.0"
api_version: "59.0"
git:
default_branch: master
prefix_feature: feature/
Expand Down
Loading

0 comments on commit 33bb241

Please sign in to comment.