Skip to content

Commit

Permalink
Use correct device password if password was set before connecting to …
Browse files Browse the repository at this point in the history
…it (#94)
  • Loading branch information
Shutgun authored Oct 18, 2022
1 parent 7450fa1 commit 7bb573c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions devolo_plc_api/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ async def _get_device_info(self) -> None:
self.product = self._info[service_type]["properties"].get("Product", "")
self.serial_number = self._info[service_type]["properties"]["SN"]
self.device = DeviceApi(ip=self.ip, session=self._session, info=self._info[service_type])
self.device.password = self.password

async def _get_plcnet_info(self) -> None:
"""Get information from the devolo PlcNet API."""
Expand Down
1 change: 0 additions & 1 deletion devolo_plc_api/device_api/deviceapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ from __future__ import annotations
from ..clients.protobuf import Protobuf
from httpx import AsyncClient as AsyncClient
from typing import Any
from typing_extensions import Concatenate as Concatenate

class DeviceApi(Protobuf):
features: list[str]
Expand Down
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.8.1] - 2022/10/18

### Fixed

- Use correct device password if password was set before connecting to it

## [v0.8.0] - 2022/05/06

### Added
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ urls = {changelog = "https://github.com/2Fake/devolo_plc_api/docs/CHANGELOG.md",
[project.optional-dependencies]
dev = [
"pre-commit",
"mypy>=0.981"
]
test = [
"pytest",
Expand Down
12 changes: 3 additions & 9 deletions script/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,12 @@ def generate_stubs() -> None:
target = os.path.join(options.output_dir, target)
files.append(target)
with generate_guarded(mod.module, target, options.ignore_errors, options.verbose):
generate_stub_from_ast(
mod, target, options.parse_only, options.pyversion, options.include_private, options.export_less
)
generate_stub_from_ast(mod, target, options.parse_only, options.include_private, options.export_less)


def generate_stub_from_ast(
mod: StubSource, target: str, parse_only: bool, pyversion: tuple[int, int], include_private: bool, export_less: bool
) -> None:
def generate_stub_from_ast(mod: StubSource, target: str, parse_only: bool, include_private: bool, export_less: bool) -> None:
"""Use analysed (or just parsed) AST to generate type stub for single file."""
gen = ApiStubGenerator(
mod.runtime_all, pyversion=pyversion, include_private=include_private, analyzed=not parse_only, export_less=export_less
)
gen = ApiStubGenerator(mod.runtime_all, include_private=include_private, analyzed=not parse_only, export_less=export_less)
mod.ast.accept(gen)
if "annotations" in mod.ast.future_import_flags:
gen.add_import_line("from __future__ import annotations\n")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ async def test__get_device_info(self, mock_device: Device, test_data: TestData):
"""Test that information from the device API are filled in."""
with patch("devolo_plc_api.device.Device._get_zeroconf_info"):
device_info = test_data.device_info[DEVICEAPI]
mock_device.password = "super_secret"
await mock_device.async_connect()
assert mock_device.firmware_date == date.fromisoformat(device_info["properties"]["FirmwareDate"])
assert mock_device.firmware_version == device_info["properties"]["FirmwareVersion"]
assert mock_device.serial_number == device_info["properties"]["SN"]
assert mock_device.mt_number == device_info["properties"]["MT"]
assert mock_device.product == device_info["properties"]["Product"]
assert isinstance(mock_device.device, DeviceApi)
assert mock_device.device.password == mock_device.password

@pytest.mark.asyncio
async def test__get_device_info_multicast(self, test_data: TestData):
Expand Down

0 comments on commit 7bb573c

Please sign in to comment.