test_conformance_001.py 1.1 KB

123456789101112131415161718192021222324
  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. @pytest.mark.asyncio
  6. async def test_conformance_001():
  7. dt = datetime(2020,1,1,12,0,0,tzinfo=timezone(offset=timedelta(hours=4)))
  8. msg = create_message('oadrCreateOpt', **{'opt_id': generate_id(),
  9. 'opt_type': enums.OPT.OPT_IN,
  10. 'opt_reason': enums.OPT_REASON.ECONOMIC,
  11. 'ven_id': generate_id(),
  12. 'created_date_time': dt,
  13. 'request_id': generate_id(),
  14. 'event_id': generate_id(),
  15. 'modification_number': 1,
  16. 'targets': []})
  17. parsed_type, parsed_msg = parse_message(msg)
  18. assert parsed_msg['created_date_time'].tzinfo == timezone.utc
  19. assert parsed_msg['created_date_time'] == dt.astimezone(timezone.utc)