99"""
1010from __future__ import annotations
1111
12- import io
13- import math
14- import struct
1512import textwrap
16- from unittest .mock import MagicMock , patch
13+ from unittest .mock import patch
1714
1815import numpy as np
1916import pytest
20- import rasterio
2117from rasterio .io import MemoryFile
22- from rasterio .transform import from_bounds
2318
2419from app .models .coverage_request import CoveragePredictionRequest
2520from app .services .clutter import (
@@ -227,39 +222,39 @@ def test_climate_enumeration(self):
227222 }
228223 for name , expected_int in climates .items ():
229224 content = self ._make_lrp (radio_climate = name )
230- lines = [l .split (";" )[0 ].strip () for l in content .strip ().split ("\n " )]
225+ lines = [ln .split (";" )[0 ].strip () for ln in content .strip ().split ("\n " )]
231226 assert lines [4 ] == str (expected_int ), f"{ name } should map to { expected_int } "
232227
233228 def test_polarization_enumeration (self ):
234229 h_content = self ._make_lrp (polarization = "horizontal" )
235230 v_content = self ._make_lrp (polarization = "vertical" )
236- h_line = [l .split (";" )[0 ].strip () for l in h_content .split ("\n " )][5 ]
237- v_line = [l .split (";" )[0 ].strip () for l in v_content .split ("\n " )][5 ]
231+ h_line = [ln .split (";" )[0 ].strip () for ln in h_content .split ("\n " )][5 ]
232+ v_line = [ln .split (";" )[0 ].strip () for ln in v_content .split ("\n " )][5 ]
238233 assert h_line == "0"
239234 assert v_line == "1"
240235
241236 def test_situation_fraction_normalized (self ):
242237 content = self ._make_lrp (situation_fraction = 50.0 )
243- lines = [l .split (";" )[0 ].strip () for l in content .strip ().split ("\n " )]
238+ lines = [ln .split (";" )[0 ].strip () for ln in content .strip ().split ("\n " )]
244239 assert float (lines [6 ]) == pytest .approx (0.50 )
245240
246241 def test_time_fraction_normalized (self ):
247242 content = self ._make_lrp (time_fraction = 90.0 )
248- lines = [l .split (";" )[0 ].strip () for l in content .strip ().split ("\n " )]
243+ lines = [ln .split (";" )[0 ].strip () for ln in content .strip ().split ("\n " )]
249244 assert float (lines [7 ]) == pytest .approx (0.90 )
250245
251246 def test_erp_calculation (self ):
252247 # ERP = 10^((tx_power + tx_gain - system_loss - 30) / 10) Watts
253248 # The LRP file formats ERP with %.2f, so we allow rounding tolerance.
254249 content = self ._make_lrp (tx_power = 17.0 , tx_gain = 2.0 , system_loss = 2.0 )
255- lines = [l .split (";" )[0 ].strip () for l in content .strip ().split ("\n " )]
250+ lines = [ln .split (";" )[0 ].strip () for ln in content .strip ().split ("\n " )]
256251 expected_erp = 10 ** ((17.0 + 2.0 - 2.0 - 30 ) / 10 )
257252 assert float (lines [8 ]) == pytest .approx (expected_erp , abs = 0.01 )
258253
259254 def test_erp_with_zero_gain_loss (self ):
260255 # 20 dBm, 0 dB gain, 0 dB loss → 10^((20-30)/10) = 0.1 W
261256 content = self ._make_lrp (tx_power = 20.0 , tx_gain = 0.0 , system_loss = 0.0 )
262- lines = [l .split (";" )[0 ].strip () for l in content .strip ().split ("\n " )]
257+ lines = [ln .split (";" )[0 ].strip () for ln in content .strip ().split ("\n " )]
263258 assert float (lines [8 ]) == pytest .approx (0.1 , rel = 1e-3 )
264259
265260 def test_frequency_in_content (self ):
@@ -278,31 +273,31 @@ def test_returns_bytes(self):
278273
279274 def test_has_32_levels (self ):
280275 content = Splat ._create_splat_dcf ("plasma" , - 130.0 , - 80.0 ).decode ()
281- data_lines = [l for l in content .split ("\n " ) if l .strip () and not l .startswith (";" )]
276+ data_lines = [ln for ln in content .split ("\n " ) if ln .strip () and not ln .startswith (";" )]
282277 assert len (data_lines ) == 32
283278
284279 def test_levels_from_max_to_min (self ):
285280 content = Splat ._create_splat_dcf ("plasma" , - 130.0 , - 80.0 ).decode ()
286- data_lines = [l for l in content .split ("\n " ) if l .strip () and not l .startswith (";" )]
281+ data_lines = [ln for ln in content .split ("\n " ) if ln .strip () and not ln .startswith (";" )]
287282 first_dbm = int (data_lines [0 ].split (":" )[0 ].strip ())
288283 last_dbm = int (data_lines [- 1 ].split (":" )[0 ].strip ())
289284 assert first_dbm > last_dbm # max at top, min at bottom
290285
291286 def test_max_dbm_is_first_level (self ):
292287 content = Splat ._create_splat_dcf ("plasma" , - 130.0 , - 80.0 ).decode ()
293- data_lines = [l for l in content .split ("\n " ) if l .strip () and not l .startswith (";" )]
288+ data_lines = [ln for ln in content .split ("\n " ) if ln .strip () and not ln .startswith (";" )]
294289 first_dbm = int (data_lines [0 ].split (":" )[0 ].strip ())
295290 assert first_dbm == - 80
296291
297292 def test_min_dbm_is_last_level (self ):
298293 content = Splat ._create_splat_dcf ("plasma" , - 130.0 , - 80.0 ).decode ()
299- data_lines = [l for l in content .split ("\n " ) if l .strip () and not l .startswith (";" )]
294+ data_lines = [ln for ln in content .split ("\n " ) if ln .strip () and not ln .startswith (";" )]
300295 last_dbm = int (data_lines [- 1 ].split (":" )[0 ].strip ())
301296 assert last_dbm == - 130
302297
303298 def test_rgb_values_in_range (self ):
304299 content = Splat ._create_splat_dcf ("plasma" , - 130.0 , - 80.0 ).decode ()
305- data_lines = [l for l in content .split ("\n " ) if l .strip () and not l .startswith (";" )]
300+ data_lines = [ln for ln in content .split ("\n " ) if ln .strip () and not ln .startswith (";" )]
306301 for line in data_lines :
307302 rgb_part = line .split (":" )[1 ]
308303 r , g , b = [int (x ) for x in rgb_part .split ("," )]
0 commit comments