Skip to content

Commit 4cdb8fb

Browse files
pre-commit-ci[bot]PritamP20
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci Signed-off-by: PritamP20 <pripritam7@gmail.com>
1 parent d9ee7ee commit 4cdb8fb

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

ardupilot_methodic_configurator/data_model_signing_config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ def from_dict(cls, data: dict[str, Any]) -> "SigningConfig":
103103
"""
104104
# Filter to only known fields to avoid unexpected arguments
105105
known_fields = {
106-
"enabled", "sign_outgoing", "allow_unsigned_in",
107-
"accept_unsigned_callbacks", "timestamp_offset", "link_id",
106+
"enabled",
107+
"sign_outgoing",
108+
"allow_unsigned_in",
109+
"accept_unsigned_callbacks",
110+
"timestamp_offset",
111+
"link_id",
108112
}
109113
filtered_data = {k: v for k, v in data.items() if k in known_fields}
110114
return cls(**filtered_data)

tests/sitl_signing.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
def is_sitl_available(connection: str = SITL_CONNECTION, timeout: float = 5.0) -> bool:
3333
"""Check if SITL is running and accepting connections."""
3434
try:
35-
from pymavlink import mavutil
35+
from pymavlink import mavutil
3636

3737
master = mavutil.mavlink_connection(connection, baud=115200)
3838
heartbeat = master.wait_heartbeat(timeout=timeout)
3939
master.close()
4040
return heartbeat is not None
41-
except Exception:
41+
except Exception:
4242
return False
4343

44+
4445
pytestmark = [
4546
pytest.mark.integration,
4647
pytest.mark.skipif(
@@ -131,9 +132,7 @@ def test_can_setup_signing_with_generated_key(
131132
else:
132133
assert "not supported" in error_msg.lower() or "error" in error_msg.lower()
133134

134-
def test_can_disable_signing_after_setup(
135-
self, connected_fc: FlightController, signing_keystore: SigningKeystore
136-
) -> None:
135+
def test_can_disable_signing_after_setup(self, connected_fc: FlightController, signing_keystore: SigningKeystore) -> None:
137136
"""
138137
User can disable signing after it has been configured.
139138
@@ -213,9 +212,7 @@ def test_signing_with_invalid_link_id_raises_error(
213212
with pytest.raises(ValueError, match="link_id"):
214213
connected_fc.setup_signing(key, link_id=256)
215214

216-
def test_can_reconnect_after_signing_enabled(
217-
self, signing_keystore: SigningKeystore
218-
) -> None:
215+
def test_can_reconnect_after_signing_enabled(self, signing_keystore: SigningKeystore) -> None:
219216
"""
220217
FlightController can reconnect after signing was enabled.
221218
@@ -232,7 +229,7 @@ def test_can_reconnect_after_signing_enabled(
232229
fc.setup_signing(key)
233230

234231
fc.disconnect()
235-
time.sleep(1)
232+
time.sleep(1)
236233

237234
new_result = fc.connect(device=SITL_CONNECTION)
238235

tests/test_signing_config.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
"""
1212

1313
import json
14-
from pathlib import Path
15-
from unittest.mock import patch
1614

1715
import pytest
1816

@@ -123,14 +121,16 @@ def test_user_can_deserialize_config_from_json(self) -> None:
123121
THEN: A SigningConfig instance should be created
124122
AND: All values should match the JSON input
125123
"""
126-
json_str = json.dumps({
127-
"enabled": True,
128-
"sign_outgoing": False,
129-
"allow_unsigned_in": True,
130-
"accept_unsigned_callbacks": True,
131-
"timestamp_offset": 100,
132-
"link_id": 7,
133-
})
124+
json_str = json.dumps(
125+
{
126+
"enabled": True,
127+
"sign_outgoing": False,
128+
"allow_unsigned_in": True,
129+
"accept_unsigned_callbacks": True,
130+
"timestamp_offset": 100,
131+
"link_id": 7,
132+
}
133+
)
134134

135135
config = SigningConfig.from_json(json_str)
136136

@@ -206,7 +206,7 @@ def test_invalid_boolean_type_raises_validation_error(self) -> None:
206206
THEN: A ValueError should be raised
207207
"""
208208
with pytest.raises(ValueError, match="enabled"):
209-
SigningConfig(enabled="true")
209+
SigningConfig(enabled="true")
210210

211211
def test_invalid_timestamp_type_raises_validation_error(self) -> None:
212212
"""
@@ -217,7 +217,7 @@ def test_invalid_timestamp_type_raises_validation_error(self) -> None:
217217
THEN: A ValueError should be raised
218218
"""
219219
with pytest.raises(ValueError, match="timestamp_offset"):
220-
SigningConfig(timestamp_offset="100")
220+
SigningConfig(timestamp_offset="100")
221221

222222

223223
class TestVehicleSigningConfig:

tests/test_signing_keystore.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@
1010
SPDX-License-Identifier: GPL-3.0-or-later
1111
"""
1212

13-
import json
14-
import os
15-
from pathlib import Path
16-
from unittest.mock import MagicMock, patch
13+
from unittest.mock import patch
1714

1815
import pytest
1916

2017
from ardupilot_methodic_configurator.backend_signing_keystore import (
2118
SIGNING_KEY_LENGTH,
2219
SigningKeystore,
23-
StoredKey,
2420
)
2521

2622

0 commit comments

Comments
 (0)