Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

* Extra validation check to ensure the quantity is strictly positive.
* Extra validation check to ensure the quantity and price are within the allowed bounds.
* Add more edge cases to the integration tests
* Add more edge cases to the integration tests.
* Add idiomatic string representations for `Power` and `Price` classes.

## Bug Fixes

Expand Down
16 changes: 16 additions & 0 deletions src/frequenz/client/electricity_trading/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ def to_pb(self) -> price_pb2.Price:
decimal_amount.value = str(self.amount)
return price_pb2.Price(amount=decimal_amount, currency=self.currency.to_pb())

def __str__(self) -> str:
"""Return string representation of the Price object.

Returns:
String representation of the Price object.
"""
return f"{self.amount} {self.currency.name}"


@dataclass(frozen=True)
class Power:
Expand Down Expand Up @@ -144,6 +152,14 @@ def to_pb(self) -> power_pb2.Power:
decimal_mw.value = str(self.mw)
return power_pb2.Power(mw=decimal_mw)

def __str__(self) -> str:
"""Return the string representation of the Power object.

Returns:
The string representation of the Power object.
"""
return f"{self.mw} MW"


class EnergyMarketCodeType(enum.Enum):
"""
Expand Down
Loading