ace-pluto's picture
build-spec-tasks: the training tasks of Kerberos 35B-A3B
845996e verified
Raw History Blame Contribute Delete
2.79 kB
--- a/src/fastapi_cloud_cli/api/_models.py
+++ b/src/fastapi_cloud_cli/api/_models.py
@@ -107,6 +107,7 @@
building_image = "building_image"
building_image_failed = "building_image_failed"
building_image_failed_timeout = "building_image_failed_timeout"
+ build_skipped = "build_skipped"
deploying = "deploying"
deploying_skipped = "deploying_skipped"
deploying_failed = "deploying_failed"
@@ -133,6 +134,7 @@
cls.building_image: "Building Image",
cls.building_image_failed: "Build Failed",
cls.building_image_failed_timeout: "Build Timed Out",
+ cls.build_skipped: "Build Skipped",
cls.deploying: "Deploying Image",
cls.deploying_skipped: "Deployment Skipped",
cls.deploying_failed: "Deployment Failed",
@@ -145,7 +147,7 @@
cls.degraded: "Degraded",
cls.expired: "Expired",
cls.failed: "Failed",
- }[status]
+ }.get(status, "Unknown")
class Deployment(BaseModel):
--- /dev/null
+++ b/tests/test_deployment_status.py
@@ -0,0 +1,40 @@
+from fastapi_cloud_cli.api._models import DeploymentStatus
+
+
+def test_build_skipped_status_exists():
+ # Fails today: DeploymentStatus has no build_skipped member (src/fastapi_cloud_cli/api/_models.py, class DeploymentStatus).
+ assert DeploymentStatus("build_skipped") is DeploymentStatus.build_skipped
+
+
+def test_build_skipped_human_readable():
+ # Fails today: no build_skipped member, so the lookup raises KeyError (src/fastapi_cloud_cli/api/_models.py, to_human_readable).
+ assert (
+ DeploymentStatus.to_human_readable(DeploymentStatus.build_skipped)
+ == "Build Skipped"
+ )
+
+
+def test_unknown_status_returns_unknown():
+ # Fails today: the dict lookup `}[status]` raises KeyError for a non-member (src/fastapi_cloud_cli/api/_models.py, to_human_readable).
+ assert DeploymentStatus.to_human_readable("some_new_status") == "Unknown"
+
+
+def test_existing_labels_unchanged():
+ # Fails today: "some_new_status" raises KeyError before the fix; guards the existing mapping.
+ assert DeploymentStatus.to_human_readable(DeploymentStatus.success) == "Ready"
+ assert (
+ DeploymentStatus.to_human_readable(DeploymentStatus.verifying_skipped)
+ == "Verification Skipped"
+ )
+ assert (
+ DeploymentStatus.to_human_readable(DeploymentStatus.deploying_skipped)
+ == "Deployment Skipped"
+ )
+
+
+def test_every_member_has_a_label():
+ # Fails today: build_skipped is missing, and any gap would surface as "Unknown".
+ for member in DeploymentStatus:
+ label = DeploymentStatus.to_human_readable(member)
+ assert isinstance(label, str)
+ assert label != "Unknown"