Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
731 additions
and
456 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
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,52 +1,27 @@ | ||
"""Unit test for KNX/IP ConnectionStateRequests.""" | ||
import asyncio | ||
"""Unit test for KNX/IP Body base class.""" | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
from xknx import XKNX | ||
from xknx.knxip import KNXIPBody | ||
from xknx.knxip import KNXIPBody, KNXIPBodyResponse | ||
|
||
|
||
class Test_KNXIPBody(unittest.TestCase): | ||
"""Test class for KNX/IP ConnectionStateRequests.""" | ||
|
||
# pylint: disable=too-many-public-methods,invalid-name | ||
"""Test base class for KNX/IP bodys.""" | ||
|
||
def setUp(self): | ||
"""Set up test class.""" | ||
self.loop = asyncio.new_event_loop() | ||
asyncio.set_event_loop(self.loop) | ||
|
||
def tearDown(self): | ||
"""Tear down test class.""" | ||
self.loop.close() | ||
|
||
def test_warn_calculated_length(self): | ||
"""Test correct warn message if calculated_length is missing.""" | ||
xknx = XKNX() | ||
body = KNXIPBody(xknx) | ||
with patch("logging.Logger.warning") as mock_warn: | ||
body.calculated_length() | ||
mock_warn.assert_called_with( | ||
"'calculated_length()' not implemented for %s", "KNXIPBody" | ||
) | ||
|
||
def test_warn_to_knx(self): | ||
"""Test correct warn message if to_knx is missing.""" | ||
xknx = XKNX() | ||
body = KNXIPBody(xknx) | ||
with patch("logging.Logger.warning") as mock_warn: | ||
body.to_knx() | ||
mock_warn.assert_called_with( | ||
"'to_knx()' not implemented for %s", "KNXIPBody" | ||
) | ||
|
||
def test_warn_from_knx(self): | ||
"""Test correct warn message if from_knx is missing.""" | ||
xknx = XKNX() | ||
body = KNXIPBody(xknx) | ||
with patch("logging.Logger.warning") as mock_warn: | ||
body.from_knx((0x75, 0x0B, 0x1C, 0x17, 0x07, 0x18, 0x00, 0x00)) | ||
mock_warn.assert_called_with( | ||
"'from_knx()' not implemented for %s", "KNXIPBody" | ||
) | ||
self.xknx = XKNX() | ||
|
||
@patch.multiple(KNXIPBody, __abstractmethods__=set()) | ||
def test_body_attributes(self): | ||
"""Test attributes of KNXIPBody base class.""" | ||
body = KNXIPBody(self.xknx) | ||
self.assertTrue(hasattr(body, "service_type")) | ||
|
||
@patch.multiple(KNXIPBodyResponse, __abstractmethods__=set()) | ||
def test_response_attributes(self): | ||
"""Test attributes of KNXIPBodyResponse base class.""" | ||
response = KNXIPBodyResponse(self.xknx) | ||
self.assertTrue(hasattr(response, "service_type")) | ||
self.assertTrue(hasattr(response, "status_code")) |
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
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
Oops, something went wrong.