Skip to content

Commit 1455bd5

Browse files
committed
FIX: unit tests and remove most FBT003 linter exceptions
1 parent c20a0e3 commit 1455bd5

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

ARCHITECTURE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,22 @@ For example, to add support for German:
315315
mkdir de
316316
```
317317

318-
Now add the language to the end of the `LANGUAGE_CHOICES` array in the `ardupilot_methodic_configurator/internationalization.py` file.
318+
Add the language to the end of the `LANGUAGE_CHOICES` array in the `ardupilot_methodic_configurator/internationalization.py` file.
319319

320320
For example, to add support for German:
321321

322322
```python
323323
LANGUAGE_CHOICES = ['en', 'zh_CN', 'pt', 'de']
324324
```
325325

326+
Add it also to the test on `tests\test_internationalization.py` file:
327+
328+
```python
329+
def test_language_choices(self) -> None:
330+
expected_languages = ["en", "zh_CN", "pt", "de", "it"]
331+
assert expected_languages == LANGUAGE_CHOICES
332+
```
333+
326334
### 3. Create a New PO File
327335

328336
Inside your newly created language directory, create a new `.po` file using the `.pot` template:

tests/test_backend_filesystem.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TestLocalFilesystem(unittest.TestCase): # pylint: disable=too-many-public
2525
def test_read_params_from_files(self) -> None:
2626
"""Test reading parameters from files with proper filtering."""
2727
mock_vehicle_dir = "/mock/dir"
28-
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", False) # noqa: FBT003
28+
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", allow_editing_template_files=False)
2929

3030
with (
3131
patch(
@@ -57,7 +57,7 @@ def test_str_to_bool(self) -> None:
5757
def test_re_init(self) -> None:
5858
"""Test reinitializing the filesystem with new parameters."""
5959
mock_vehicle_dir = "/mock/dir"
60-
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", False) # noqa: FBT003
60+
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", allow_editing_template_files=False)
6161

6262
with (
6363
patch.object(filesystem, "load_vehicle_components_json_data", return_value=True),
@@ -73,7 +73,7 @@ def test_re_init(self) -> None:
7373
def test_vehicle_configuration_files_exist(self) -> None:
7474
"""Test checking if vehicle configuration files exist."""
7575
mock_vehicle_dir = "/mock/dir"
76-
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", False) # noqa: FBT003
76+
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", allow_editing_template_files=False)
7777

7878
with (
7979
patch("ardupilot_methodic_configurator.backend_filesystem.os_path.exists", return_value=True),
@@ -96,7 +96,7 @@ def test_vehicle_configuration_files_exist(self) -> None:
9696
def test_rename_parameter_files(self) -> None:
9797
"""Test renaming parameter files."""
9898
mock_vehicle_dir = "/mock/dir"
99-
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", False) # noqa: FBT003
99+
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", allow_editing_template_files=False)
100100
filesystem.configuration_steps = {"new_file.param": {"old_filenames": ["old_file.param"]}}
101101

102102
with (
@@ -185,7 +185,7 @@ def test_getcwd(self) -> None:
185185
"""Test getting current working directory."""
186186
mock_vehicle_dir = "/mock/dir"
187187
mock_cwd = "/test/dir"
188-
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", False) # noqa: FBT003
188+
filesystem = LocalFilesystem(mock_vehicle_dir, "ArduCopter", "4.3.0", allow_editing_template_files=False)
189189

190190
with patch("ardupilot_methodic_configurator.backend_filesystem.os_getcwd", return_value=mock_cwd) as mock_getcwd:
191191
result = filesystem.getcwd()
@@ -308,7 +308,7 @@ def test_get_start_file_empty_files(self) -> None:
308308
"""Test get_start_file with empty files list."""
309309
lfs = LocalFilesystem("vehicle_dir", "vehicle_type", None, allow_editing_template_files=False)
310310
lfs.file_parameters = {}
311-
result = lfs.get_start_file(1, True) # noqa: FBT003
311+
result = lfs.get_start_file(1, tcal_available=True)
312312
assert result == ""
313313

314314
def test_get_eval_variables_with_none(self) -> None:
@@ -386,19 +386,19 @@ def test_get_start_file(self) -> None:
386386
lfs.file_parameters = {"01_file.param": {}, "02_file.param": {}, "03_file.param": {}}
387387

388388
# Test with explicit index
389-
result = lfs.get_start_file(1, True) # noqa: FBT003
389+
result = lfs.get_start_file(1, tcal_available=True)
390390
assert result == "02_file.param"
391391

392392
# Test with out of range index
393-
result = lfs.get_start_file(5, True) # noqa: FBT003
393+
result = lfs.get_start_file(5, tcal_available=True)
394394
assert result == "03_file.param"
395395

396396
# Test with tcal available
397-
result = lfs.get_start_file(-1, True) # noqa: FBT003
397+
result = lfs.get_start_file(-1, tcal_available=True)
398398
assert result == "01_file.param"
399399

400400
# Test with tcal not available
401-
result = lfs.get_start_file(-1, False) # noqa: FBT003
401+
result = lfs.get_start_file(-1, tcal_available=False)
402402
assert result == "03_file.param"
403403

404404
def test_get_eval_variables(self) -> None:
@@ -522,15 +522,15 @@ def test_export_to_param(self) -> None:
522522
mock_format.return_value = "formatted_params"
523523

524524
# Test with documentation annotation
525-
lfs.export_to_param(test_params, "test.param", True) # noqa: FBT003
525+
lfs.export_to_param(test_params, "test.param", annotate_doc=True)
526526
mock_format.assert_called_with(test_params)
527527
mock_export.assert_called_with("formatted_params", os_path.join("vehicle_dir", "test.param"))
528528
mock_update.assert_called_once()
529529

530530
# Test without documentation annotation
531531
mock_export.reset_mock()
532532
mock_update.reset_mock()
533-
lfs.export_to_param(test_params, "test.param", False) # noqa: FBT003
533+
lfs.export_to_param(test_params, "test.param", annotate_doc=False)
534534
mock_export.assert_called_once()
535535
mock_update.assert_not_called()
536536

tests/test_backend_internet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_download_file_unicode_error(mock_get) -> None:
174174
def test_get_release_info_invalid_release(mock_get) -> None:
175175
mock_get.side_effect = requests_RequestException()
176176
with pytest.raises(requests_RequestException):
177-
get_release_info("latest", False) # noqa: FBT003
177+
get_release_info("latest", should_be_pre_release=False)
178178

179179

180180
@patch("ardupilot_methodic_configurator.backend_internet.requests_get")

tests/test_internationalization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_load_translation_fallback(self) -> None:
4848
assert translation_function == identity_function # pylint: disable=comparison-with-callable
4949

5050
def test_language_choices(self) -> None:
51-
expected_languages = ["en", "zh_CN", "pt", "de"]
51+
expected_languages = ["en", "zh_CN", "pt", "de", "it"]
5252
assert expected_languages == LANGUAGE_CHOICES
5353

5454

0 commit comments

Comments
 (0)