Skip to content

Commit

Permalink
Merge branch 'main' into bug/run-tests=not-infer-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jstvz authored Oct 25, 2023
2 parents 932285c + fe7f564 commit 17274e5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
11 changes: 9 additions & 2 deletions cumulusci/tasks/metadeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ def _init_task(self):
Path(self.labels_path).mkdir(parents=True, exist_ok=True)

if plan_name := self.options.get("plan"):
if self.project_config.lookup(f"plans__{plan_name}") is None:
raise TaskOptionsError(
f"Plan {plan_name} not found in project configuration"
)
plan_configs = {
plan_name: self.project_config.lookup(f"plans__{plan_name}")
}
self.plan_configs = plan_configs
else:
self.plan_configs = self.project_config.plans
# Handled exception for no plan
if self.plan_configs is None or len(self.plan_configs) == 0:
raise CumulusCIException(
"No plan found to publish in project configuration"
)

self._load_labels()

Expand All @@ -107,7 +116,6 @@ def _run_task(self):
raise CumulusCIException(
f"No slug found in MetaDeploy for product {product} from {repo_url}"
)

if not self.dry_run:
version = self._find_or_create_version(product)
if self.labels_path and "slug" in product:
Expand Down Expand Up @@ -138,7 +146,6 @@ def _run_task(self):
)
project_config.set_keychain(self.project_config.keychain)

# Create each plan
for plan_name, plan_config in self.plan_configs.items():
self._add_plan_labels(
plan_name=plan_name,
Expand Down
42 changes: 42 additions & 0 deletions cumulusci/tasks/tests/test_metadeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,14 @@ def test_find_product__not_found(self):
)
project_config = create_project_config()
project_config.config["project"]["git"]["repo_url"] = "EXISTING_REPO"
project_config.config["plans"] = {
"install": {
"title": "Test Install",
"slug": "install",
"tier": "primary",
"steps": {1: {"flow": "install_prod"}},
}
}
project_config.keychain.set_service(
"metadeploy",
"test_alias",
Expand Down Expand Up @@ -485,6 +493,37 @@ def test_init_task__named_plan(self):
task._init_task()
assert expected_plans == task.plan_configs

@pytest.mark.parametrize(
"options, errortype,errormsg",
[
(
{"tag": "release/1.0"},
CumulusCIException,
"No plan found to publish in project configuration",
),
(
{"tag": "release/1.0", "plan": "install"},
TaskOptionsError,
"Plan install not found in project configuration",
),
],
)
def test_init_task_no_plan(self, options, errortype, errormsg):
project_config = create_project_config()
project_config.config["project"]["git"]["repo_url"] = "EXISTING_REPO"
project_config.keychain.set_service(
"metadeploy",
"test_alias",
ServiceConfig({"url": "https://metadeploy", "token": "TOKEN"}),
)
task_config = TaskConfig({"options": options})
task = Publish(project_config, task_config)
with pytest.raises(
errortype,
match=errormsg,
):
task._init_task()

@responses.activate
def test_find_or_create_plan_template__not_found(self):
responses.add(
Expand Down Expand Up @@ -540,6 +579,9 @@ def test_freeze_steps__skip(self):
"tier": "primary",
"steps": {1: {"task": "None"}},
}
project_config.config["plans"] = {
"Test Install": plan_config,
}
task_config = TaskConfig({"options": {"tag": "release/1.0"}})
task = Publish(project_config, task_config)
task._init_task()
Expand Down
4 changes: 2 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ CumulusCI makes it easy to create, connect, and manage orgs. The
`cci org` top-level command helps you work with orgs.

To learn about working with orgs in detail, read
(scratch-orgs) and
(connected-orgs).
[](scratch-orgs) and
[](connected-orgs).

(manage-services)=

Expand Down

0 comments on commit 17274e5

Please sign in to comment.