test_objects.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from openleadr import objects, enums
  2. from datetime import datetime, timedelta
  3. from openleadr.messaging import create_message, parse_message
  4. from pprint import pprint
  5. def test_oadr_event():
  6. event = objects.Event(
  7. event_descriptor=objects.EventDescriptor(
  8. event_id=1,
  9. modification_number=0,
  10. market_context='MarketContext1',
  11. event_status=enums.EVENT_STATUS.NEAR),
  12. active_period=objects.ActivePeriod(
  13. dtstart=datetime.now(),
  14. duration=timedelta(minutes=10)),
  15. event_signals=[objects.EventSignal(
  16. intervals=[
  17. objects.Interval(
  18. dtstart=datetime.now(),
  19. duration=timedelta(minutes=5),
  20. uid=0,
  21. signal_payload=1),
  22. objects.Interval(
  23. dtstart=datetime.now(),
  24. duration=timedelta(minutes=5),
  25. uid=1,
  26. signal_payload=2)],
  27. target=objects.Target(
  28. ven_id='1234'
  29. ),
  30. signal_name=enums.SIGNAL_NAME.LOAD_CONTROL,
  31. signal_type=enums.SIGNAL_TYPE.LEVEL,
  32. signal_id=1,
  33. current_value=0
  34. )],
  35. target=objects.Target(
  36. ven_id='1234'
  37. )
  38. )
  39. response = objects.Response(response_code=200,
  40. response_description='OK',
  41. request_id='1234')
  42. pprint(event)
  43. msg = create_message('oadrDistributeEvent', response=response, events=[event])
  44. pprint(msg)
  45. message_type, message_payload = parse_message(msg)