test_objects.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. targets=[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. targets=[objects.Target(
  36. ven_id='1234'
  37. )]
  38. )
  39. response = objects.Response(response_code=200,
  40. response_description='OK',
  41. request_id='1234')
  42. msg = create_message('oadrDistributeEvent', response=response, events=[event])
  43. message_type, message_payload = parse_message(msg)