test_conformance_014.py 2.2 KB

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