Skip to content

Commit

Permalink
Merge branch 'feature/RestAPIDeploy' of https://github.com/SFDO-Tooli…
Browse files Browse the repository at this point in the history
…ng/CumulusCI into feature/RestAPIDeploy
  • Loading branch information
aditya-balachander committed Sep 21, 2023
2 parents 1c749f5 + 2c206c1 commit 1b8e3bd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions cumulusci/cli/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def org_info(runtime, org_name, print_json):
"instance_url",
"instance_name",
"is_sandbox",
"namespace",
"namespaced",
"org_id",
"org_type",
Expand Down
6 changes: 3 additions & 3 deletions cumulusci/cli/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def callback(*args, **kwargs):
set_global_default = kwargs.pop("default", False)

serv_conf = dict(
(k, v) for k, v in list(kwargs.items()) if v is not None
(k, v.strip()) for k, v in list(kwargs.items()) if v is not None
) # remove None values

# A service can define a callable to validate the service config
Expand Down Expand Up @@ -305,7 +305,7 @@ def service_update(
for attr in attributes:
attr_name, attr_value = attr
if attr_name in service_config.config:
service_config.config[attr_name] = attr_value
service_config.config[attr_name] = attr_value.strip()
attributes_were_updated = True
else:
available_attributes = ", ".join(service_attributes)
Expand All @@ -324,7 +324,7 @@ def service_update(
)
if user_input != "":
attributes_were_updated = True
service_config.config[attr] = user_input
service_config.config[attr] = user_input.strip()

if attributes_were_updated:
runtime.keychain.set_service(service_type, service_name, service_config)
Expand Down
2 changes: 2 additions & 0 deletions cumulusci/cli/tests/test_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ def test_org_info(self):
"default": True,
"password": None,
"connected_app": "built-in",
"namespace": "test",
}
org_config.expires = date.today()
org_config.latest_api_version = "42.0"
Expand All @@ -557,6 +558,7 @@ def test_org_info(self):
["\x1b[1mconnected_app\x1b[0m", "built-in"],
["\x1b[1mdays\x1b[0m", "1"],
["\x1b[1mdefault\x1b[0m", "True"],
["\x1b[1mnamespace\x1b[0m", "test"],
["\x1b[1mpassword\x1b[0m", "None"],
],
)
Expand Down
53 changes: 53 additions & 0 deletions cumulusci/cli/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,28 @@ def test_service_connect_validator_failure():
run_cli_command("service", "connect", "test", "test-alias", runtime=runtime)


def test_service_connect_without_whitespaces():
attr_value = " Sample attr value "
attr_value_without_whitespaces = "Sample attr value"
runtime = BaseCumulusCI(
config={"services": {"test": {"attributes": {"attr": {"required": False}}}}}
)

result = run_cli_command(
"service",
"connect",
"test",
"test-alias",
"--attr",
attr_value,
runtime=runtime,
)

result = runtime.keychain.get_service("test", "test-alias")
assert attr_value != result.attr
assert attr_value_without_whitespaces == result.attr


def test_service_update__success():
# Create a new color-picker service type
runtime = CliRuntime(
Expand Down Expand Up @@ -334,6 +356,37 @@ def test_service_update__success():
assert original_color not in result.output


def test_service_update_without_whitespaces():
# Create a new color-picker service type
runtime = CliRuntime(
config={
"services": {"color-picker": {"attributes": {"color": {"required": False}}}}
}
)
# Setup an existing service of type color-picker
original_color = "Turquoise"
runtime.keychain.set_service(
"color-picker",
"foo",
ServiceConfig({"color": original_color}),
)
# Update the existing service
chosen_color = " Maroon "
chosen_color_without_whitespaces = "Maroon"
result = run_cli_command(
"service",
"update",
"color-picker",
"foo",
input=f"{chosen_color}\n",
runtime=runtime,
)
# ensure info was written without whitespaces
result = runtime.keychain.get_service("color-picker", "foo")
assert chosen_color != result.color
assert chosen_color_without_whitespaces == result.color


def test_service_update_headless__success():
# Create a new color-picker service type
runtime = CliRuntime(
Expand Down

0 comments on commit 1b8e3bd

Please sign in to comment.