|
28 | 28 | MarketSide, |
29 | 29 | Order, |
30 | 30 | OrderDetail, |
| 31 | + OrderExecutionOption, |
31 | 32 | OrderState, |
32 | 33 | OrderType, |
33 | 34 | Power, |
34 | 35 | Price, |
| 36 | + PublicOrder, |
| 37 | + PublicOrderBookFilter, |
35 | 38 | PublicTrade, |
36 | 39 | PublicTradeFilter, |
37 | 40 | StateDetail, |
|
172 | 175 | quantity=power_pb2.Power(mw=decimal_pb2.Decimal(value="5.00")), |
173 | 176 | state=electricity_trading_pb2.TradeState.TRADE_STATE_ACTIVE, |
174 | 177 | ) |
175 | | - |
| 178 | +PUBLIC_ORDER = PublicOrder( |
| 179 | + public_order_id=42, |
| 180 | + delivery_area=DeliveryArea(code="XYZ", code_type=EnergyMarketCodeType.EUROPE_EIC), |
| 181 | + delivery_period=DeliveryPeriod(start=START_TIME, duration=timedelta(minutes=15)), |
| 182 | + side=MarketSide.BUY, |
| 183 | + price=Price(amount=Decimal("100.00"), currency=Currency.EUR), |
| 184 | + quantity=Power(mw=Decimal("5.00")), |
| 185 | + execution_option=OrderExecutionOption.AON, |
| 186 | + create_time=CREATE_TIME, |
| 187 | + update_time=MODIFICATION_TIME, |
| 188 | +) |
| 189 | +PUBLIC_ORDER_PB = electricity_trading_pb2.PublicOrderBookRecord( |
| 190 | + id=42, |
| 191 | + delivery_area=delivery_area_pb2.DeliveryArea( |
| 192 | + code="XYZ", |
| 193 | + code_type=delivery_area_pb2.EnergyMarketCodeType.ENERGY_MARKET_CODE_TYPE_EUROPE_EIC, |
| 194 | + ), |
| 195 | + delivery_period=delivery_duration_pb2.DeliveryPeriod( |
| 196 | + start=START_TIME_PB, |
| 197 | + duration=delivery_duration_pb2.DeliveryDuration.DELIVERY_DURATION_15, |
| 198 | + ), |
| 199 | + side=electricity_trading_pb2.MarketSide.MARKET_SIDE_BUY, |
| 200 | + price=price_pb2.Price( |
| 201 | + amount=decimal_pb2.Decimal(value="100.00"), |
| 202 | + currency=price_pb2.Price.Currency.CURRENCY_EUR, |
| 203 | + ), |
| 204 | + quantity=power_pb2.Power(mw=decimal_pb2.Decimal(value="5.00")), |
| 205 | + execution_option=electricity_trading_pb2.OrderExecutionOption.ORDER_EXECUTION_OPTION_AON, |
| 206 | + create_time=CREATE_TIME_PB, |
| 207 | + update_time=MODIFICATION_TIME_PB, |
| 208 | +) |
| 209 | +PUBLIC_ORDER_BOOK_FILTER = PublicOrderBookFilter( |
| 210 | + delivery_area=DeliveryArea(code="XYZ", code_type=EnergyMarketCodeType.EUROPE_EIC), |
| 211 | + delivery_period=DeliveryPeriod(start=START_TIME, duration=timedelta(minutes=15)), |
| 212 | + side=MarketSide.SELL, |
| 213 | +) |
| 214 | +PUBLIC_ORDER_BOOK_FILTER_PB = electricity_trading_pb2.PublicOrderBookFilter( |
| 215 | + delivery_area=delivery_area_pb2.DeliveryArea( |
| 216 | + code="XYZ", |
| 217 | + code_type=delivery_area_pb2.EnergyMarketCodeType.ENERGY_MARKET_CODE_TYPE_EUROPE_EIC, |
| 218 | + ), |
| 219 | + delivery_period=delivery_duration_pb2.DeliveryPeriod( |
| 220 | + start=START_TIME_PB, |
| 221 | + duration=delivery_duration_pb2.DeliveryDuration.DELIVERY_DURATION_15, |
| 222 | + ), |
| 223 | + side=electricity_trading_pb2.MarketSide.MARKET_SIDE_SELL, |
| 224 | +) |
176 | 225 | GRIDPOOL_ORDER_FILTER = GridpoolOrderFilter( |
177 | 226 | order_states=[OrderState.ACTIVE, OrderState.CANCELED], |
178 | 227 | side=MarketSide.BUY, |
@@ -653,3 +702,39 @@ def test_update_order_to_pb_with_empty_values() -> None: |
653 | 702 | # Make sure all attributes are None |
654 | 703 | non_none_attrs = converted_update_order.ListFields() |
655 | 704 | assert len(non_none_attrs) == 0 |
| 705 | + |
| 706 | + |
| 707 | +def test_public_order_to_pb() -> None: |
| 708 | + """Test the client public order type conversion to protobuf.""" |
| 709 | + assert_conversion_to_pb( |
| 710 | + original=PUBLIC_ORDER, |
| 711 | + expected_pb=PUBLIC_ORDER_PB, |
| 712 | + assert_func=assert_equal, |
| 713 | + ) |
| 714 | + |
| 715 | + |
| 716 | +def test_public_order_from_pb() -> None: |
| 717 | + """Test the client public order type conversion from protobuf.""" |
| 718 | + assert_conversion_from_pb( |
| 719 | + original_pb=PUBLIC_ORDER_PB, |
| 720 | + expected=PUBLIC_ORDER, |
| 721 | + assert_func=assert_equal, |
| 722 | + ) |
| 723 | + |
| 724 | + |
| 725 | +def test_public_order_book_filter_to_pb() -> None: |
| 726 | + """Test the client public order book filter type conversion to protobuf.""" |
| 727 | + assert_conversion_to_pb( |
| 728 | + original=PUBLIC_ORDER_BOOK_FILTER, |
| 729 | + expected_pb=PUBLIC_ORDER_BOOK_FILTER_PB, |
| 730 | + assert_func=assert_equal, |
| 731 | + ) |
| 732 | + |
| 733 | + |
| 734 | +def test_public_order_book_filter_from_pb() -> None: |
| 735 | + """Test the client public order book filter type conversion from protobuf.""" |
| 736 | + assert_conversion_from_pb( |
| 737 | + original_pb=PUBLIC_ORDER_BOOK_FILTER_PB, |
| 738 | + expected=PUBLIC_ORDER_BOOK_FILTER, |
| 739 | + assert_func=assert_equal, |
| 740 | + ) |
0 commit comments