MatMaul / pynetgear

Python library to control Netgear wireless routers through the SOAP-api.
MIT License
236 stars 75 forks source link

Test failures #109

Open fabaff opened 2 years ago

fabaff commented 2 years ago

With 0.9.1 the tests are not passing locally with pytest.

============================= test session starts ==============================
platform linux -- Python 3.8.8, pytest-6.2.2, py-1.9.0, pluggy-0.13.1
rootdir: /build/source, configfile: setup.cfg, testpaths: tests
collected 5 items                                                              

tests/test_getAttachedDevices.py FFFFF                                   [100%]

=================================== FAILURES ===================================
_________________ TestGetAttachedDevices.test_invalidResponse __________________

self = <tests.test_getAttachedDevices.TestGetAttachedDevices testMethod=test_invalidResponse>

    def test_invalidResponse(self):
        spy = NetgearSpy(RESPONSE_INVALID)
        mocked_netgear = mock.Mock(wraps=spy)
>       result = spy.get_attached_devices()

tests/test_getAttachedDevices.py:36: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_getAttachedDevices.NetgearSpy object at 0x7ffff5b65be0>

    def get_attached_devices(self):
        """
        Return list of connected devices to the router.

        Returns None if error occurred.
        """
        _LOGGER.debug("Get attached devices")

        success, response = self._make_request(
            SERVICE_DEVICE_INFO,
            "GetAttachDevice"
        )

        if not success:
            _LOGGER.error("Get attached devices failed")
            return None

        success, node = _find_node(
>           response.text,
            ".//GetAttachDeviceResponse/NewAttachDevice")
E       AttributeError: 'str' object has no attribute 'text'

pynetgear/__init__.py:280: AttributeError
___________________ TestGetAttachedDevices.test_noSignalType ___________________

self = <tests.test_getAttachedDevices.TestGetAttachedDevices testMethod=test_noSignalType>

    def test_noSignalType(self):
        spy = NetgearSpy(RESPONSE_NO_SIGNAL_TYPE)
        mocked_netgear = mock.Mock(wraps=spy)

>       result = spy.get_attached_devices()

tests/test_getAttachedDevices.py:12: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_getAttachedDevices.NetgearSpy object at 0x7ffff593f250>

    def get_attached_devices(self):
        """
        Return list of connected devices to the router.

        Returns None if error occurred.
        """
        _LOGGER.debug("Get attached devices")

        success, response = self._make_request(
            SERVICE_DEVICE_INFO,
            "GetAttachDevice"
        )

        if not success:
            _LOGGER.error("Get attached devices failed")
            return None

        success, node = _find_node(
>           response.text,
            ".//GetAttachDeviceResponse/NewAttachDevice")
E       AttributeError: 'str' object has no attribute 'text'
[...]

pynetgear/__init__.py:280: AttributeError
=========================== short test summary info ============================
FAILED tests/test_getAttachedDevices.py::TestGetAttachedDevices::test_invalidResponse
FAILED tests/test_getAttachedDevices.py::TestGetAttachedDevices::test_noSignalType
FAILED tests/test_getAttachedDevices.py::TestGetAttachedDevices::test_responseMissingSplitChar
FAILED tests/test_getAttachedDevices.py::TestGetAttachedDevices::test_responseUnknownDevice
FAILED tests/test_getAttachedDevices.py::TestGetAttachedDevices::test_withSignalType
============================== 5 failed in 0.38s ===============================

Same result by invoking the tests directly.

test_invalidResponse (tests.test_getAttachedDevices.TestGetAttachedDevices) ... ERROR
test_noSignalType (tests.test_getAttachedDevices.TestGetAttachedDevices) ... ERROR
test_responseMissingSplitChar (tests.test_getAttachedDevices.TestGetAttachedDevices) ... ERROR
test_responseUnknownDevice (tests.test_getAttachedDevices.TestGetAttachedDevices) ... ERROR
test_withSignalType (tests.test_getAttachedDevices.TestGetAttachedDevices) ... ERROR

======================================================================
ERROR: test_invalidResponse (tests.test_getAttachedDevices.TestGetAttachedDevices)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/source/tests/test_getAttachedDevices.py", line 36, in test_invalidResponse
    result = spy.get_attached_devices()
  File "/build/source/pynetgear/__init__.py", line 280, in get_attached_devices
    response.text,
AttributeError: 'str' object has no attribute 'text'
[...]