async def fixture_manager(
        session: ClientSession,
        connector: Connector) -> AsyncGenerator[SystemManager, None]:
    manager = SystemManager("user", "pass", session, "pymultiMATIC", SERIAL)
    await connector.login()
    with mock.patch.object(connector, "request", wraps=connector.request):
        manager._connector = connector
        yield manager
Exemplo n.º 2
0
async def fixture_manager(session: ClientSession,
                          connector: Connector) \
        -> AsyncGenerator[SystemManager, None]:
    manager = SystemManager('user', 'pass', session, 'pymultiMATIC', SERIAL)
    await connector.login()
    with mock.patch.object(connector, 'request', wraps=connector.request):
        manager._connector = connector
        yield manager
async def test_serial_not_fixed_relogin(session: ClientSession,
                                        connector: Connector,
                                        resp: aioresponses) -> None:
    manager = SystemManager("user", "pass", session, "pymultiMATIC")

    with open(path("files/responses/zone"), "r") as file:
        raw_zone = json.loads(file.read())

    with open(path("files/responses/facilities"), "r") as file:
        facilities = json.loads(file.read())

    facilities["body"]["facilitiesList"][0]["serialNumber"] = "123"

    url_zone1 = urls.zone(serial=SERIAL, id="zone")
    url_zone2 = urls.zone(serial="123", id="zone")

    url_facilities = urls.facilities_list(serial=SERIAL)

    resp.get(url_zone1, payload=raw_zone, status=200)
    resp.get(url_zone2, payload=raw_zone, status=200)
    resp.get(url_facilities, payload=facilities, status=200)

    mock_auth(resp)

    await manager.get_zone("zone")
    assert manager._serial == SERIAL
    assert not manager._fixed_serial

    connector._clear_cookies()

    await manager.get_zone("zone")
    assert manager._serial == "123"
Exemplo n.º 4
0
    def __init__(self, hass, username, password, serial):
        """Initialize hub."""
        # pylint: disable=import-outside-toplevel
        from pymultimatic.systemmanager import SystemManager

        session = async_create_clientsession(hass)
        self._manager = SystemManager(
            username, password, session, DEFAULT_SMART_PHONE_ID, serial
        )
        self.system: System = None
        self.update_system = Throttle(DEFAULT_SCAN_INTERVAL)(self._update_system)
        self._hass = hass
Exemplo n.º 5
0
    def __init__(self, hass, username, password, serial):
        """Initialize hub."""
        from pymultimatic.systemmanager import SystemManager
        from pymultimatic.model import System

        session = async_create_clientsession(hass)
        self._manager = SystemManager(
            username, password, session, DEFAULT_SMART_PHONE_ID, serial
        )
        self.system: System = None
        self.update_system = Throttle(DEFAULT_SCAN_INTERVAL)(self._update_system)
        self._hass = hass
        async_track_time_interval(hass, self._hvac_update, timedelta(minutes=10))
async def test_serial_not_fixed_login(session: ClientSession,
                                      resp: aioresponses) -> None:
    manager = SystemManager("user", "pass", session, "pymultiMATIC")

    with open(path("files/responses/zone"), "r") as file:
        raw_zone = json.loads(file.read())

    url = urls.zone(serial=SERIAL, id="zone")
    resp.get(url, payload=raw_zone, status=200)

    await manager.get_zone("zone")
    assert manager._serial == SERIAL
    assert not manager._fixed_serial
Exemplo n.º 7
0
async def test_serial_not_fixed_login(session: ClientSession,
                                      resp: aioresponses) -> None:
    manager = SystemManager('user', 'pass', session, 'pymultiMATIC')

    with open(path('files/responses/zone'), 'r') as file:
        raw_zone = json.loads(file.read())

    url = urls.zone(serial=SERIAL, id='zone')
    resp.get(url, payload=raw_zone, status=200)

    await manager.get_zone('zone')
    assert manager._serial == SERIAL
    assert not manager._fixed_serial
async def test_logout_serial_not_fixed(session: ClientSession) -> None:
    manager = SystemManager("user", "pass", session, "pymultiMATIC")
    assert await manager.login()
    await manager.logout()
    assert manager._serial is None
async def test_login(session: ClientSession) -> None:
    manager = SystemManager("user", "pass", session, "pymultiMATIC")
    assert await manager.login()
async def test_serial_not_fixed(session: ClientSession) -> None:
    manager = SystemManager("user", "pass", session, "pymultiMATIC")
    assert not manager._fixed_serial
Exemplo n.º 11
0
async def test_logout_serial_not_fixed(session: ClientSession) -> None:
    manager = SystemManager('user', 'pass', session, 'pymultiMATIC')
    assert await manager.login()
    await manager.logout()
    assert manager._serial is None
Exemplo n.º 12
0
async def test_login(session: ClientSession) -> None:
    manager = SystemManager('user', 'pass', session, 'pymultiMATIC')
    assert await manager.login()
Exemplo n.º 13
0
async def test_serial_not_fixed(session: ClientSession) -> None:
    manager = SystemManager('user', 'pass', session, 'pymultiMATIC')
    assert not manager._fixed_serial