2026-03-21 17:51:36 +01:00
|
|
|
"""Tests for python_pkg.geo_data.__init__ module."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
|
|
|
|
from python_pkg.geo_data import (
|
|
|
|
|
clear_cache,
|
|
|
|
|
download_all_poland_data,
|
|
|
|
|
download_all_warsaw_data,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestDownloadAllWarsawData:
|
|
|
|
|
"""Tests for download_all_warsaw_data."""
|
|
|
|
|
|
Reduce per-file-ignores by fixing lint violations across codebase
Fix ruff violations in ~15 source files and ~60+ test files to minimize
per-file-ignores in pyproject.toml. Remaining ignores are justified with
comments explaining why each suppression is necessary.
Source fixes: FBT003 (keyword args), S310 (URL validation), SLF001
(private access), T201 (print→logging), C901 (complexity), E501 (line
length), E402 (import order).
Test fixes: SIM117 (combined with), FBT (boolean args), PERF203 (try in
loop), S310/S607 (URLs/executables), E402/E501 (imports/lines), S108
(tmp paths), PLR0913 (too many args), ARG (unused args), ANN (type
annotations), RUF059 (unused unpacked vars), PT019 (fixture naming).
Remaining per-file-ignores (with justifications):
- Tests: ARG, D, PLC0415, PLR2004, S101, SLF001
- music_gen sources: PLC0415 (heavy ML lazy imports)
- moviepy_showcase: PLC0415 (circular dependency)
- generate_images: PLR0913 (matplotlib helpers need many params)
- praca_magisterska_video: E501, E402 (long paths, mpl.use)
2026-03-25 18:58:05 +01:00
|
|
|
def test_calls_all_warsaw_functions(self) -> None:
|
|
|
|
|
with (
|
|
|
|
|
patch("python_pkg.geo_data.sys.stdout"),
|
|
|
|
|
patch("python_pkg.geo_data.get_warsaw_boundary") as mock_boundary,
|
|
|
|
|
patch("python_pkg.geo_data.get_vistula_river") as mock_vistula,
|
|
|
|
|
patch("python_pkg.geo_data.get_warsaw_bridges") as mock_bridges,
|
|
|
|
|
patch("python_pkg.geo_data.get_warsaw_metro_stations") as mock_metro,
|
|
|
|
|
patch("python_pkg.geo_data.get_warsaw_streets") as mock_streets,
|
|
|
|
|
patch("python_pkg.geo_data.get_warsaw_landmarks") as mock_landmarks,
|
|
|
|
|
patch("python_pkg.geo_data.get_warsaw_osiedla") as mock_osiedla,
|
|
|
|
|
):
|
|
|
|
|
download_all_warsaw_data()
|
|
|
|
|
mock_boundary.assert_called_once()
|
|
|
|
|
mock_vistula.assert_called_once()
|
|
|
|
|
mock_bridges.assert_called_once()
|
|
|
|
|
mock_metro.assert_called_once()
|
|
|
|
|
mock_streets.assert_called_once()
|
|
|
|
|
mock_landmarks.assert_called_once()
|
|
|
|
|
mock_osiedla.assert_called_once()
|
2026-03-21 17:51:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestDownloadAllPolandData:
|
|
|
|
|
"""Tests for download_all_poland_data."""
|
|
|
|
|
|
|
|
|
|
@patch("python_pkg.geo_data.get_poland_boundary")
|
|
|
|
|
@patch("python_pkg.geo_data.get_polish_gminy")
|
|
|
|
|
@patch("python_pkg.geo_data.get_polish_powiaty")
|
|
|
|
|
@patch("python_pkg.geo_data.get_polish_wojewodztwa")
|
|
|
|
|
@patch("python_pkg.geo_data.sys.stdout")
|
|
|
|
|
def test_calls_all_poland_functions(
|
|
|
|
|
self,
|
|
|
|
|
mock_stdout: MagicMock,
|
|
|
|
|
mock_woj: MagicMock,
|
|
|
|
|
mock_powiaty: MagicMock,
|
|
|
|
|
mock_gminy: MagicMock,
|
|
|
|
|
mock_boundary: MagicMock,
|
|
|
|
|
) -> None:
|
|
|
|
|
download_all_poland_data()
|
|
|
|
|
mock_woj.assert_called_once()
|
|
|
|
|
mock_powiaty.assert_called_once()
|
|
|
|
|
mock_gminy.assert_called_once()
|
|
|
|
|
mock_boundary.assert_called_once()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestClearCache:
|
|
|
|
|
"""Tests for clear_cache."""
|
|
|
|
|
|
|
|
|
|
@patch("python_pkg.geo_data.shutil.rmtree")
|
|
|
|
|
@patch("python_pkg.geo_data.CACHE_DIR")
|
|
|
|
|
@patch("python_pkg.geo_data.sys.stdout")
|
|
|
|
|
def test_cache_exists(
|
|
|
|
|
self,
|
|
|
|
|
mock_stdout: MagicMock,
|
|
|
|
|
mock_cache_dir: MagicMock,
|
|
|
|
|
mock_rmtree: MagicMock,
|
|
|
|
|
) -> None:
|
|
|
|
|
mock_cache_dir.exists.return_value = True
|
|
|
|
|
clear_cache()
|
|
|
|
|
mock_rmtree.assert_called_once_with(mock_cache_dir)
|
|
|
|
|
|
|
|
|
|
@patch("python_pkg.geo_data.CACHE_DIR")
|
|
|
|
|
@patch("python_pkg.geo_data.sys.stdout")
|
|
|
|
|
def test_cache_not_exists(
|
|
|
|
|
self,
|
|
|
|
|
mock_stdout: MagicMock,
|
|
|
|
|
mock_cache_dir: MagicMock,
|
|
|
|
|
) -> None:
|
|
|
|
|
mock_cache_dir.exists.return_value = False
|
|
|
|
|
clear_cache()
|