TomerFi

shay_utils_test

Jun 21st, 2021
474
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from unittest.mock import AsyncMock, Mock, patch
  2.  
  3. from pytest import fixture, mark
  4.  
  5. from aioswitcher.bridge import SwitcherBridge
  6. from aioswitcher.shay_utils import async_start_bridge
  7.  
  8. pytestmark = mark.asyncio
  9.  
  10.  
  11. @fixture
  12. def callback_mock():
  13.     return Mock()
  14.  
  15.  
  16. @fixture
  17. def home_assistant_mock():
  18.     return AsyncMock()
  19.  
  20.  
  21. @patch("aioswitcher.bridge.SwitcherBridge.start")
  22. async def test_async_start_bridge(start_mock, home_assistant_mock, callback_mock):
  23.     with patch.object(SwitcherBridge, "__new__", new=AsyncMock) as bridge:
  24.         bridge.start = start_mock
  25.         await async_start_bridge(home_assistant_mock, callback_mock)
  26.  
  27.     start_mock.assert_called_once_with()
RAW Paste Data