@@ -315,24 +315,48 @@ def test_price_from_pb() -> None:
315315 )
316316
317317
318- def test_energy_to_pb () -> None :
319- """Test the client energy type conversions to protobuf."""
318+ def test_price_formatting () -> None :
319+ """Test the client price type formatting."""
320+ price = Price (amount = Decimal ("800" ), currency = Currency .JPY )
321+ assert str (price ) == "800 JPY"
322+ price = Price (amount = Decimal ("-100.3" ), currency = Currency .CHF )
323+ assert str (price ) == "-100.3 CHF"
324+ price = Price (amount = Decimal ("-103.00" ), currency = Currency .USD )
325+ assert str (price ) == "-103.00 USD"
326+ price = Price (amount = Decimal ("400.123" ), currency = Currency .EUR )
327+ assert str (price ) == "400.123 EUR"
328+
329+
330+ def test_power_to_pb () -> None :
331+ """Test the client power type conversions to protobuf."""
320332 assert_conversion_to_pb (
321333 original = Power (mw = Decimal ("5" )),
322334 expected_pb = power_pb2 .Power (mw = decimal_pb2 .Decimal (value = "5" )),
323335 assert_func = assert_equal ,
324336 )
325337
326338
327- def test_energy_from_pb () -> None :
328- """Test the client energy type conversions from protobuf."""
339+ def test_power_from_pb () -> None :
340+ """Test the client power type conversions from protobuf."""
329341 assert_conversion_from_pb (
330342 original_pb = power_pb2 .Power (mw = decimal_pb2 .Decimal (value = "5" )),
331343 expected = Power (mw = Decimal ("5" )),
332344 assert_func = assert_equal ,
333345 )
334346
335347
348+ def test_power_formatting () -> None :
349+ """Test the client power type formatting."""
350+ power = Power (mw = Decimal ("5" ))
351+ assert str (power ) == "5 MW"
352+ power = Power (mw = Decimal ("5.1" ))
353+ assert str (power ) == "5.1 MW"
354+ power = Power (mw = Decimal ("5.100" ))
355+ assert str (power ) == "5.100 MW"
356+ power = Power (mw = Decimal ("-5.123" ))
357+ assert str (power ) == "-5.123 MW"
358+
359+
336360def test_delivery_duration_to_pb () -> None :
337361 """Test the client delivery duration type conversions to protobuf."""
338362 assert_conversion_to_pb (
0 commit comments