From 37788f22fe1632e0cf4929d5be92cdcfe7359670 Mon Sep 17 00:00:00 2001 From: "MagicMock/mock.effective_git_name/128893997444000" Date: Sat, 16 May 2026 18:59:47 +0000 Subject: [PATCH] fix(profile): expose volume_size_gb on Profile Prerequisite for web-terminal#20 (Subscription card pricing display). The Subscribe button label needs disk size to compute the monthly price via the pricing formula in landing-page/Pricing.astro. Without this, the trial-state CTA can only show a placeholder. ShardBase already carries volume_size_gb; Profile.from_shard now propagates it (via getattr for safety against subclassed shard models). Follows up on PR#83 / issue#77 subscription work. --- shard_core/data_model/profile.py | 2 ++ tests/conftest.py | 1 + tests/test_profile.py | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/shard_core/data_model/profile.py b/shard_core/data_model/profile.py index c7064e1..c7c9331 100644 --- a/shard_core/data_model/profile.py +++ b/shard_core/data_model/profile.py @@ -20,6 +20,7 @@ class Profile(BaseModel): delete_after: Optional[datetime] = None vm_size: VMSize max_vm_size: Optional[VMSize] = None + volume_size_gb: int | None = None subscription: Optional[ShardSubscriptionSummary] = None @classmethod @@ -35,6 +36,7 @@ def from_shard(cls, shard: ShardBase): max_vm_size=( VMSize(shard.max_vm_size.value.lower()) if shard.max_vm_size else None ), + volume_size_gb=getattr(shard, "volume_size_gb", None), subscription=getattr(shard, "subscription", None), ) diff --git a/tests/conftest.py b/tests/conftest.py index 66ed62d..b73017c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -260,6 +260,7 @@ async def app_client(mocker) -> AsyncGenerator[AsyncClient]: status=ShardStatus.ASSIGNED, shared_secret="foosecretbar", cloud=Cloud.OVHCLOUD, + volume_size_gb=30, ) diff --git a/tests/test_profile.py b/tests/test_profile.py index 3034baa..0a53339 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -39,3 +39,11 @@ async def test_profile_without_subscription_is_none( response.raise_for_status() profile = Profile.model_validate(response.json()) assert profile.subscription is None + + +async def test_profile_includes_volume_size_gb(requests_mock, app_client: AsyncClient): + response = await app_client.get("protected/management/profile") + response.raise_for_status() + profile = Profile.model_validate(response.json()) + assert profile.volume_size_gb == conftest.mock_shard.volume_size_gb + assert profile.volume_size_gb == 30