1010 PAYG_GROUP ,
1111 PRICING_GROUPS ,
1212 GroupEntity ,
13+ Price ,
1314 Pricing ,
1415 PricingEntity ,
1516 PricingModel ,
@@ -64,17 +65,21 @@ async def test_get_pricing_aggregate(mock_client):
6465 storage_entity = result [PricingEntity .STORAGE ]
6566 assert isinstance (storage_entity , PricingPerEntity )
6667 assert "storage" in storage_entity .price
67- assert storage_entity .price ["storage" ].holding == Decimal ("0.333333333" )
68+ storage_price = storage_entity .price ["storage" ]
69+ assert isinstance (storage_price , Price ) # Add type assertion for mypy
70+ assert storage_price .holding == Decimal ("0.333333333" )
6871
6972 # Check program entity has correct compute unit details
7073 program_entity = result [PricingEntity .PROGRAM ]
7174 assert isinstance (program_entity , PricingPerEntity )
75+ assert program_entity .compute_unit is not None # Ensure compute_unit is not None
7276 assert program_entity .compute_unit .vcpus == 1
7377 assert program_entity .compute_unit .memory_mib == 2048
7478 assert program_entity .compute_unit .disk_mib == 2048
7579
7680 # Check tiers in instance entity
7781 instance_entity = result [PricingEntity .INSTANCE ]
82+ assert instance_entity .tiers is not None # Ensure tiers is not None
7883 assert len (instance_entity .tiers ) == 6
7984 assert instance_entity .tiers [0 ].id == "tier-1"
8085 assert instance_entity .tiers [0 ].compute_units == 1
@@ -96,11 +101,14 @@ async def test_get_pricing_for_services(mock_client):
96101 assert PricingEntity .INSTANCE not in result
97102
98103 # Verify specific pricing data
99- assert result [PricingEntity .STORAGE ].price ["storage" ].holding == Decimal (
100- "0.333333333"
101- )
102- assert result [PricingEntity .PROGRAM ].price ["compute_unit" ].payg == Decimal ("0.011" )
103- assert result [PricingEntity .PROGRAM ].price ["compute_unit" ].holding == Decimal ("200" )
104+ storage_price = result [PricingEntity .STORAGE ].price ["storage" ]
105+ assert isinstance (storage_price , Price ) # Ensure it's a Price object
106+ assert storage_price .holding == Decimal ("0.333333333" )
107+
108+ compute_price = result [PricingEntity .PROGRAM ].price ["compute_unit" ]
109+ assert isinstance (compute_price , Price ) # Ensure it's a Price object
110+ assert compute_price .payg == Decimal ("0.011" )
111+ assert compute_price .holding == Decimal ("200" )
104112
105113 # Test Case 2: Using pre-fetched pricing aggregate
106114 pricing_info = await pricing_service .get_pricing_aggregate ()
@@ -131,10 +139,12 @@ async def test_get_pricing_for_services(mock_client):
131139 gpu_result = await pricing_service .get_pricing_for_services (gpu_services )
132140 assert len (gpu_result ) == 2
133141 # Check GPU models are present
134- assert (
135- gpu_result [PricingEntity .INSTANCE_GPU_STANDARD ].tiers [0 ].model == "RTX 4000 ADA"
136- )
137- assert gpu_result [PricingEntity .INSTANCE_GPU_PREMIUM ].tiers [1 ].model == "H100"
142+ standard_tiers = gpu_result [PricingEntity .INSTANCE_GPU_STANDARD ].tiers
143+ premium_tiers = gpu_result [PricingEntity .INSTANCE_GPU_PREMIUM ].tiers
144+ assert standard_tiers is not None
145+ assert premium_tiers is not None
146+ assert standard_tiers [0 ].model == "RTX 4000 ADA"
147+ assert premium_tiers [1 ].model == "H100"
138148
139149
140150@pytest .mark .asyncio
@@ -156,17 +166,27 @@ async def test_get_pricing_for_gpu_services(mock_client):
156166
157167 # Verify GPU standard pricing and details
158168 gpu_standard = result [PricingEntity .INSTANCE_GPU_STANDARD ]
159- assert gpu_standard .price ["compute_unit" ].payg == Decimal ("0.28" )
160- assert len (gpu_standard .tiers ) == 5
161- assert gpu_standard .tiers [0 ].model == "RTX 4000 ADA"
162- assert gpu_standard .tiers [0 ].vram == 20480
169+ compute_unit_price = gpu_standard .price ["compute_unit" ]
170+ assert isinstance (compute_unit_price , Price )
171+ assert compute_unit_price .payg == Decimal ("0.28" )
172+
173+ standard_tiers = gpu_standard .tiers
174+ assert standard_tiers is not None
175+ assert len (standard_tiers ) == 5
176+ assert standard_tiers [0 ].model == "RTX 4000 ADA"
177+ assert standard_tiers [0 ].vram == 20480
163178
164179 # Verify GPU premium pricing and details
165180 gpu_premium = result [PricingEntity .INSTANCE_GPU_PREMIUM ]
166- assert gpu_premium .price ["compute_unit" ].payg == Decimal ("0.56" )
167- assert len (gpu_premium .tiers ) == 2
168- assert gpu_premium .tiers [1 ].model == "H100"
169- assert gpu_premium .tiers [1 ].vram == 81920
181+ premium_compute_price = gpu_premium .price ["compute_unit" ]
182+ assert isinstance (premium_compute_price , Price )
183+ assert premium_compute_price .payg == Decimal ("0.56" )
184+
185+ premium_tiers = gpu_premium .tiers
186+ assert premium_tiers is not None
187+ assert len (premium_tiers ) == 2
188+ assert premium_tiers [1 ].model == "H100"
189+ assert premium_tiers [1 ].vram == 81920
170190
171191
172192@pytest .mark .asyncio
0 commit comments