diff --git a/coverage_point_calculator/src/speedtest.rs b/coverage_point_calculator/src/speedtest.rs index 37980ce09..000623e68 100644 --- a/coverage_point_calculator/src/speedtest.rs +++ b/coverage_point_calculator/src/speedtest.rs @@ -53,6 +53,34 @@ pub struct Speedtest { } impl Speedtest { + /// Construct the minimum required speedtests for a given tier + pub fn mock(tier: SpeedtestTier) -> Vec { + // SpeedtestTier is determined solely by upload_speed. + // Other values are far surpassing ::Good. + let upload_speed = BytesPs::mbps(match tier { + SpeedtestTier::Good => 10, + SpeedtestTier::Acceptable => 8, + SpeedtestTier::Degraded => 5, + SpeedtestTier::Poor => 2, + SpeedtestTier::Fail => 0, + }); + + vec![ + Speedtest { + upload_speed, + download_speed: BytesPs::mbps(150), + latency_millis: 0, + timestamp: Utc::now(), + }, + Speedtest { + upload_speed, + download_speed: BytesPs::mbps(150), + latency_millis: 0, + timestamp: Utc::now(), + }, + ] + } + pub fn multiplier(&self) -> Decimal { let upload = SpeedtestTier::from_upload(self.upload_speed); let download = SpeedtestTier::from_download(self.download_speed); @@ -125,7 +153,7 @@ impl SpeedtestTier { fn from_latency(millis: Millis) -> Self { match millis { - 00..=49 => Self::Good, + 0..=49 => Self::Good, 50..=59 => Self::Acceptable, 60..=74 => Self::Degraded, 75..=99 => Self::Poor, diff --git a/coverage_point_calculator/tests/coverage_point_calculator.rs b/coverage_point_calculator/tests/coverage_point_calculator.rs index 2ab08a945..0a7723bac 100644 --- a/coverage_point_calculator/tests/coverage_point_calculator.rs +++ b/coverage_point_calculator/tests/coverage_point_calculator.rs @@ -241,7 +241,7 @@ fn cbrs_outdoor_with_mixed_signal_level_coverage() -> Result { let radio = CoveragePoints::new( RadioType::OutdoorCbrs, RadioThreshold::Verified, - speedtests(SpeedtestTier::Good), + Speedtest::mock(SpeedtestTier::Good), vec![], // Location Trust is ignored for Cbrs vec![ top_ranked_coverage(0x8c2681a3064d9ff, SignalLevel::High), @@ -373,7 +373,7 @@ fn indoor_cbrs_radio( CoveragePoints::new( RadioType::IndoorCbrs, RadioThreshold::Verified, - speedtests(speedtest_tier), + Speedtest::mock(speedtest_tier), vec![], coverage.to_owned(), ) @@ -386,7 +386,7 @@ fn outdoor_cbrs_radio( CoveragePoints::new( RadioType::OutdoorCbrs, RadioThreshold::Verified, - speedtests(speedtest_tier), + Speedtest::mock(speedtest_tier), vec![], coverage.to_owned(), ) @@ -403,33 +403,6 @@ impl BoostedHexMap for NoBoostedHexes { } } -fn speedtests(tier: SpeedtestTier) -> Vec { - // SpeedtestTier is determined solely by upload_speed. - // Other values are far surpassing ::Good. - let upload_speed = BytesPs::mbps(match tier { - SpeedtestTier::Good => 10, - SpeedtestTier::Acceptable => 8, - SpeedtestTier::Degraded => 5, - SpeedtestTier::Poor => 2, - SpeedtestTier::Fail => 0, - }); - - vec![ - Speedtest { - upload_speed, - download_speed: BytesPs::mbps(150), - latency_millis: 0, - timestamp: Utc::now(), - }, - Speedtest { - upload_speed, - download_speed: BytesPs::mbps(150), - latency_millis: 0, - timestamp: Utc::now(), - }, - ] -} - fn top_ranked_coverage(hex: u64, signal_level: SignalLevel) -> RankedCoverage { ranked_coverage(hex, 1, signal_level) }