-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
specifing encoding for loading the fake configuration
- Loading branch information
1 parent
14fed58
commit 865547f
Showing
6 changed files
with
55 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
import pytest | ||
|
||
from unittest.mock import MagicMock | ||
from homematicip.async.connection import AsyncConnection | ||
|
||
|
||
def AsyncMock(*args, **kwargs): | ||
m = MagicMock(*args, **kwargs) | ||
|
||
async def mock_coro(*args, **kwargs): | ||
return m(*args, **kwargs) | ||
|
||
mock_coro.mock = m | ||
return mock_coro | ||
|
||
|
||
@pytest.fixture | ||
def fake_connection(event_loop): | ||
_connection = AsyncConnection(event_loop) | ||
_connection.api_call = AsyncMock(return_value='called') | ||
return _connection | ||
|
||
@pytest.fixture | ||
def async_connection(event_loop): | ||
_connection = AsyncConnection(event_loop) | ||
yield _connection | ||
_connection._websession.close() | ||
import pytest | ||
import json | ||
from unittest.mock import MagicMock | ||
from homematicip.async.connection import AsyncConnection | ||
from homematicip.home import Home | ||
from homematicip.base.base_connection import BaseConnection | ||
|
||
def AsyncMock(*args, **kwargs): | ||
m = MagicMock(*args, **kwargs) | ||
|
||
async def mock_coro(*args, **kwargs): | ||
return m(*args, **kwargs) | ||
|
||
mock_coro.mock = m | ||
return mock_coro | ||
|
||
def fake_home_download_configuration(): | ||
return json.load(open("tests/json_data/home.json", encoding="UTF-8")) | ||
|
||
@pytest.fixture | ||
def fake_home(): | ||
home = Home() | ||
home.download_configuration = fake_home_download_configuration | ||
home._connection = BaseConnection() | ||
home.get_current_state() | ||
return home | ||
|
||
@pytest.fixture | ||
def fake_connection(event_loop): | ||
_connection = AsyncConnection(event_loop) | ||
_connection.api_call = AsyncMock(return_value='called') | ||
return _connection | ||
|
||
@pytest.fixture | ||
def async_connection(event_loop): | ||
_connection = AsyncConnection(event_loop) | ||
yield _connection | ||
_connection._websession.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters