test_conformance_014.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import pytest
  2. from pyopenadr import OpenADRClient, OpenADRServer, enums
  3. from pyopenadr.utils import generate_id
  4. from pyopenadr.messaging import create_message, parse_message
  5. from datetime import datetime, timezone, timedelta
  6. from pprint import pprint
  7. import warnings
  8. @pytest.mark.asyncio
  9. async def test_conformance_014_warn():
  10. """
  11. If currentValue is included in the payload, it MUST be set to 0 (normal)
  12. when the event status is not “active” for the SIMPLE signalName.
  13. """
  14. event_id = generate_id()
  15. event = {'event_descriptor':
  16. {'event_id': event_id,
  17. 'modification_number': 0,
  18. 'modification_date': datetime.now(),
  19. 'priority': 0,
  20. 'market_context': 'MarketContext001',
  21. 'created_date_time': datetime.now(),
  22. 'event_status': enums.EVENT_STATUS.FAR,
  23. 'test_event': False,
  24. 'vtn_comment': 'No Comment'},
  25. 'active_period':
  26. {'dtstart': datetime.now() + timedelta(minutes=30),
  27. 'duration': timedelta(minutes=30)},
  28. 'event_signals':
  29. [{'intervals': [{'duration': timedelta(minutes=10),
  30. 'signal_payload': 1},
  31. {'duration': timedelta(minutes=10),
  32. 'signal_payload': 2},
  33. {'duration': timedelta(minutes=10),
  34. 'signal_payload': 3}],
  35. 'signal_name': enums.SIGNAL_NAME.SIMPLE,
  36. 'signal_type': enums.SIGNAL_TYPE.DELTA,
  37. 'signal_id': generate_id(),
  38. 'current_value': 123
  39. }]
  40. }
  41. # Create a message with this event
  42. with pytest.warns(UserWarning):
  43. msg = create_message('oadrDistributeEvent',
  44. response={'response_code': 200,
  45. 'response_description': 'OK',
  46. 'request_id': generate_id()},
  47. request_id=generate_id(),
  48. vtn_id=generate_id(),
  49. events=[event])