Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions devservices/commands/toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def add_parser(subparsers: _SubParsersAction[ArgumentParser]) -> None:
parser.add_argument(
"runtime",
help="Runtime to use for the service",
choices=[ServiceRuntime.CONTAINERIZED, ServiceRuntime.LOCAL],
choices=[runtime.value for runtime in ServiceRuntime],
nargs="?",
default=None,
)
Expand Down Expand Up @@ -74,7 +74,7 @@ def toggle(args: Namespace) -> None:
desired_runtime = get_opposite_runtime(current_runtime)
if current_runtime == desired_runtime:
console.warning(
f"{service.name} is already running in {desired_runtime} runtime"
f"{service.name} is already running in {desired_runtime.value} runtime"
)
return
if desired_runtime == ServiceRuntime.LOCAL:
Expand All @@ -89,7 +89,9 @@ def toggle(args: Namespace) -> None:

final_runtime = state.get_service_runtime(service.name)
if final_runtime == desired_runtime:
console.success(f"{service.name} is now running in {desired_runtime} runtime")
console.success(
f"{service.name} is now running in {desired_runtime.value} runtime"
)


def handle_transition_to_local_runtime(service_to_transition: Service) -> None:
Expand All @@ -105,7 +107,7 @@ def handle_transition_to_local_runtime(service_to_transition: Service) -> None:
if service_to_transition.name in active_services:
state.update_service_runtime(service_to_transition.name, ServiceRuntime.LOCAL)
console.success(
f"{service_to_transition.name} is now running in {ServiceRuntime.LOCAL} runtime"
f"{service_to_transition.name} is now running in {ServiceRuntime.LOCAL.value} runtime"
)
return

Expand Down Expand Up @@ -196,7 +198,7 @@ def restart_dependent_services(
console = Console()
with Status(
on_start=lambda: console.warning(
f"Restarting dependent services to ensure {service_name} is running in a {ServiceRuntime.CONTAINERIZED} runtime"
f"Restarting dependent services to ensure {service_name} is running in a {ServiceRuntime.CONTAINERIZED.value} runtime"
),
) as status:
for dependent_service in dependent_services:
Expand Down
16 changes: 8 additions & 8 deletions tests/commands/test_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_toggle_nothing_running(
captured = capsys.readouterr()

assert (
f"example-service is now running in {ServiceRuntime.LOCAL} runtime"
f"example-service is now running in {ServiceRuntime.LOCAL.value} runtime"
in captured.out.strip()
)

Expand All @@ -144,7 +144,7 @@ def test_toggle_nothing_running(
captured = capsys.readouterr()

assert (
f"example-service is now running in {ServiceRuntime.CONTAINERIZED} runtime"
f"example-service is now running in {ServiceRuntime.CONTAINERIZED.value} runtime"
in captured.out.strip()
)

Expand Down Expand Up @@ -197,7 +197,7 @@ def test_toggle_nothing_running_same_runtime(
captured = capsys.readouterr()

assert (
f"example-service is already running in {ServiceRuntime.CONTAINERIZED} runtime"
f"example-service is already running in {ServiceRuntime.CONTAINERIZED.value} runtime"
in captured.out.strip()
)

Expand Down Expand Up @@ -518,7 +518,7 @@ def test_handle_transition_to_local_runtime_currently_running_standalone(
captured = capsys.readouterr()

assert (
f"example-service is now running in {ServiceRuntime.LOCAL} runtime"
f"example-service is now running in {ServiceRuntime.LOCAL.value} runtime"
in captured.out.strip()
)

Expand Down Expand Up @@ -920,7 +920,7 @@ def test_restart_dependent_services_single_dependent_service_single_mode(
captured = capsys.readouterr()

assert (
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED} runtime"
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED.value} runtime"
in captured.out.strip()
)
assert "Restarting dependent-service in mode default" in captured.out.strip()
Expand Down Expand Up @@ -958,7 +958,7 @@ def test_restart_dependent_services_single_dependent_service_multiple_modes(
captured = capsys.readouterr()

assert (
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED} runtime"
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED.value} runtime"
in captured.out.strip()
)
assert "Restarting dependent-service in mode default" in captured.out.strip()
Expand Down Expand Up @@ -998,7 +998,7 @@ def test_restart_dependent_services_multiple_dependent_services_single_mode(
captured = capsys.readouterr()

assert (
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED} runtime"
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED.value} runtime"
in captured.out.strip()
)
assert "Restarting dependent-service in mode default" in captured.out.strip()
Expand Down Expand Up @@ -1055,7 +1055,7 @@ def test_restart_dependent_services_multiple_dependent_services_multiple_modes(
captured = capsys.readouterr()

assert (
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED} runtime"
f"Restarting dependent services to ensure example-service is running in a {ServiceRuntime.CONTAINERIZED.value} runtime"
in captured.out.strip()
)
assert "Restarting dependent-service in mode default" in captured.out.strip()
Expand Down
Loading