File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
src/frequenz/client/electricity_trading Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1212
1313* Extra validation check to ensure the quantity is strictly positive.
1414* Extra validation check to ensure the quantity and price are within the allowed bounds.
15- * Add more edge cases to the integration tests
15+ * Add more edge cases to the integration tests.
16+ * Add idiomatic string representations for ` Power ` and ` Price ` classes.
1617
1718## Bug Fixes
1819
Original file line number Diff line number Diff line change @@ -115,6 +115,14 @@ def to_pb(self) -> price_pb2.Price:
115115 decimal_amount .value = str (self .amount )
116116 return price_pb2 .Price (amount = decimal_amount , currency = self .currency .to_pb ())
117117
118+ def __str__ (self ) -> str :
119+ """Return string representation of the Price object.
120+
121+ Returns:
122+ String representation of the Price object.
123+ """
124+ return f"{ self .amount } { self .currency .name } "
125+
118126
119127@dataclass (frozen = True )
120128class Power :
@@ -144,6 +152,14 @@ def to_pb(self) -> power_pb2.Power:
144152 decimal_mw .value = str (self .mw )
145153 return power_pb2 .Power (mw = decimal_mw )
146154
155+ def __str__ (self ) -> str :
156+ """Return the string representation of the Power object.
157+
158+ Returns:
159+ The string representation of the Power object.
160+ """
161+ return f"{ self .mw } MW"
162+
147163
148164class EnergyMarketCodeType (enum .Enum ):
149165 """
You can’t perform that action at this time.
0 commit comments