Advertisement
chemelli74

AWS test

Jan 24th, 2022
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. async def test_service_call_extra_data(hass):
  2.     """Test service call extra data are parsed properly."""
  3.     with async_patch("homeassistant.components.aws.AioSession", new=MockAioSession):
  4.         await async_setup_component(
  5.             hass,
  6.             "aws",
  7.             {
  8.                 "aws": {
  9.                     "notify": [
  10.                         {
  11.                             "service": "sns",
  12.                             "name": "SNS Test",
  13.                             "region_name": "us-east-1",
  14.                         }
  15.                     ]
  16.                 }
  17.             },
  18.         )
  19.         await hass.async_block_till_done()
  20.  
  21.     sessions = hass.data[aws.DATA_SESSIONS]
  22.     assert sessions is not None
  23.     assert len(sessions) == 1
  24.     session = sessions.get("default")
  25.     assert isinstance(session, MockAioSession)
  26.  
  27.     assert hass.services.has_service("notify", "sns_test") is True
  28.     create_client = create_autospec(AioSession.create_client)
  29.     await hass.services.async_call(
  30.         "notify",
  31.         "sns_test",
  32.         {
  33.             "message": "test",
  34.             "target": "ARN",
  35.             "data": {"AWS.SNS.SMS.SenderID": "HA-notify"},
  36.         },
  37.         blocking=True,
  38.     )
  39.     create_client.assert_called_once_with(
  40.         MessageAttributes={"AWS.SNS.SMS.SenderID": "HA-notify"}
  41.     )
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement