fix(resources): add missing resource_type field and step definitions
CI / push-validation (pull_request) Successful in 32s
CI / helm (pull_request) Successful in 44s
CI / build (pull_request) Successful in 1m6s
CI / lint (pull_request) Successful in 1m23s
CI / quality (pull_request) Successful in 1m41s
CI / typecheck (pull_request) Successful in 1m51s
CI / security (pull_request) Successful in 1m50s
CI / integration_tests (pull_request) Successful in 4m19s
CI / unit_tests (pull_request) Failing after 6m24s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s

Fixes remaining blockers from Re-Review #12 (PR #10592):

- Add `resource_type` field to CloudResource base class, satisfying
  issue #8607 acceptance criterion that requires provider, region,
  resource_type, resource_id fields.

- Set `resource_type` in the Behave step definition for the
  resource_type acceptance scenario (changed pending_resource key
  from "type" to "resource_type").

- Fix the result_type assertion step to check resource_type instead
  of type.

- Add missing step definition `step_rejects_empty_tag_key` that matches
  the feature file scenario "AWSResource validates tags", preventing
  UndefinedStep errors in Behave.

Quality gates:
lint  (passed)
typecheck  (passed, only pre-existing warnings)

ISSUES CLOSED: #8607
This commit is contained in:
2026-05-17 02:47:21 +00:00
parent 1b280fbcfc
commit fddbecdbf0
2 changed files with 21 additions and 3 deletions
+12 -2
View File
@@ -78,7 +78,7 @@ def step_new_cloud_resource_with_type(context, resource_type: str):
"""Store a CloudResource with specified resource_type for construction."""
context.pending_resource = {
"resource_id": "cloud-test-001",
"type": resource_type,
"resource_type": resource_type,
}
@@ -98,7 +98,7 @@ def step_cloud_resource_type_accepted(context):
def step_resource_type_is(context, expected: str):
"""Assert the constructed resource has the expected resource_type."""
assert context.exc is None
assert context.result.type == expected
assert context.result.resource_type == expected
@given("a new AWSResource is being created")
@@ -250,6 +250,16 @@ def step_azure_subscription_is_lowercase(context):
assert context.result.subscription_id == "sub-123"
# --------------------- AWSResource tag validation ----------------------------
@then("it should reject tags with empty key")
def step_rejects_empty_tag_key(context):
"""Assert a ValidationError was raised for an empty tag key."""
assert context.exc is not None
assert isinstance(context.exc, ValidationError)
# ------------------------ GCPResource provider assertion --------------------
+9 -1
View File
@@ -12,7 +12,7 @@ cloud SDK operations -- actual provisioning raises
| Class | Provider | Key properties |
|-----------------|--------------|--------------------------------------------|
| ``CloudResource`` | generic | provider, type, region, resrc id, state |
| ``CloudResource`` | generic | provider, resource_type, type, region, id |
| ``AWSResource`` | AWS | arn, tags, properties |
| ``GCPResource`` | GCP | project_id, properties |
| ``AzureResource`` | Azure | sub_id, tenant_id, props |
@@ -62,6 +62,13 @@ class CloudResource(BaseModel):
...,
description="Cloud provider identifier (aws, gcp, azure).",
)
resource_type: str | None = Field(
default=None,
description=(
"Type of cloud resource within a provider "
"(e.g., s3_bucket, ec2_instance, gcs_bucket, compute_instance)."
),
)
type: str | None = Field(
default=None,
description=(
@@ -136,6 +143,7 @@ class CloudResource(BaseModel):
return (
f"{self.__class__.__name__}("
f"provider={self.provider!r}, "
f"resource_type={self.resource_type!r}, "
f"type={self.type!r}, "
f"resource_id={self.resource_id!r}, "
f"region={self.region!r})"