MCPcopy Index your code
hub / github.com/github/copilot-sdk / test_token_prices_round_trip

Method test_token_prices_round_trip

python/test_client.py:1174–1210  ·  view source on GitHub ↗

ModelBilling.from_dict/to_dict round-trips tokenPrices and longContext.

(self)

Source from the content-addressed store, hash-verified

1172
1173class TestModelBilling:
1174 def test_token_prices_round_trip(self):
1175 """ModelBilling.from_dict/to_dict round-trips tokenPrices and longContext."""
1176 wire = {
1177 "multiplier": 1.5,
1178 "tokenPrices": {
1179 "inputPrice": 2.0,
1180 "outputPrice": 8.0,
1181 "cachePrice": 0.5,
1182 "batchSize": 1000000,
1183 "contextMax": 128000,
1184 "longContext": {
1185 "inputPrice": 4.0,
1186 "outputPrice": 16.0,
1187 "cachePrice": 1.0,
1188 "contextMax": 1000000,
1189 },
1190 },
1191 }
1192
1193 billing = ModelBilling.from_dict(wire)
1194
1195 assert billing.multiplier == 1.5
1196 assert isinstance(billing.token_prices, ModelBillingTokenPrices)
1197 prices = billing.token_prices
1198 assert prices.input_price == 2.0
1199 assert prices.output_price == 8.0
1200 assert prices.cache_price == 0.5
1201 assert prices.batch_size == 1000000
1202 assert prices.context_max == 128000
1203 assert isinstance(prices.long_context, ModelBillingTokenPricesLongContext)
1204 long_context = prices.long_context
1205 assert long_context.input_price == 4.0
1206 assert long_context.output_price == 16.0
1207 assert long_context.cache_price == 1.0
1208 assert long_context.context_max == 1000000
1209
1210 assert billing.to_dict() == wire
1211
1212 def test_token_prices_absent(self):
1213 """ModelBilling without tokenPrices leaves token_prices unset."""

Callers

nothing calls this directly

Calls 2

from_dictMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected