diff --git a/requirements.txt b/requirements.txt index 2ca071e..578ef2f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,3 +46,4 @@ typed-ast==1.4.2 typing-extensions==3.7.4.3 urllib3==1.26.4 webencodings==0.5.1 +getmac==0.8.2 diff --git a/tests/test_connector.py b/tests/test_connector.py index f994364..d75ebdc 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -1,3 +1,5 @@ +from getmac import get_mac_address + from thingooConnector.device_info import DeviceInfo from thingooConnector.entity import Entity from thingooConnector.httpconnector import HTTPCredentials, HTTPConnector @@ -18,7 +20,7 @@ def test_json(): connector = HTTPConnector("#", device_info, [temp, hum], credentials) data = connector._create_registration_form() - # FIXME Testing with real macAddress + mac = get_mac_address() if str( - data) != "{'key': 'test', 'macAddress': '00:00:00:00:00:00', 'displayName': 'test device', 'entities': [{'key': 'temp', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': 'C'}, {'key': 'hum', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': '%'}]}": + data) != "{'key': 'test', 'macAddress': '" + mac + "', 'displayName': 'test device', 'entities': [{'key': 'temp', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': 'C'}, {'key': 'hum', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': '%'}]}": raise AssertionError diff --git a/thingooConnector/device_info.py b/thingooConnector/device_info.py index 220f092..13f0481 100644 --- a/thingooConnector/device_info.py +++ b/thingooConnector/device_info.py @@ -1,6 +1,4 @@ -def get_mac_address(): - # TODO Get real MAC address from device - return "00:00:00:00:00:00" +from getmac import get_mac_address class DeviceInfo: