mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-08 05:23:41 +08:00
80fbb4f6db
Register vehicle controls, planner modes, UI actions and Galaxy services after their providers exist. Wire the shared runtime entrypoints and cover their combined behavior. Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Daniel Koepping <elkoled@gmail.com> Co-authored-by: Danny <dannyirwin31@yahoo.com> Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com> Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com> Co-authored-by: Kacper Rączy <gfw.kra@gmail.com> Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com> Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Co-authored-by: stef <19478336+stefpi@users.noreply.github.com> Co-authored-by: whoisdomi <dcantu83@gmail.com> Co-authored-by: Intelli <contact@intelli.software> Co-authored-by: haraschax <6804392+haraschax@users.noreply.github.com> Co-authored-by: prabhaavp <prabhaav@msu.edu>
46 lines
2.2 KiB
Python
46 lines
2.2 KiB
Python
"""Metering uses actual hardware owner with synthetic modem/settings boundaries."""
|
|
from unittest.mock import Mock, patch
|
|
|
|
import pytest
|
|
|
|
from openpilot.common.esim.base import Profile, WEBBING_ICCID_PREFIX
|
|
from openpilot.common.hardware.comma.hardware import HardwareComma, NetworkType
|
|
|
|
|
|
@pytest.mark.parametrize('network', [NetworkType.cell2G, NetworkType.cell3G, NetworkType.cell4G, NetworkType.cell5G])
|
|
def test_prime_cellular_remains_metered_even_when_user_setting_is_false(network):
|
|
hardware = HardwareComma.__new__(HardwareComma)
|
|
hardware.get_modem_state = Mock(return_value={'iccid': WEBBING_ICCID_PREFIX + '123456789'})
|
|
with patch('openpilot.common.params.Params') as params:
|
|
assert hardware.get_network_metered(network) is True
|
|
params.assert_not_called()
|
|
|
|
|
|
@pytest.mark.parametrize('modem', [{}, {'iccid': ''}, {'iccid': 'other-sim'}])
|
|
@pytest.mark.parametrize('metered', [False, True])
|
|
def test_other_cellular_retains_saved_metered_setting(modem, metered):
|
|
hardware = HardwareComma.__new__(HardwareComma)
|
|
hardware.get_modem_state = Mock(return_value=modem)
|
|
with patch('openpilot.common.params.Params') as params:
|
|
params.return_value.get_bool.return_value = metered
|
|
assert hardware.get_network_metered(NetworkType.cell4G) is metered
|
|
params.return_value.get_bool.assert_called_once_with('GsmMetered')
|
|
|
|
|
|
def test_wifi_never_borrows_cellular_prime_override():
|
|
hardware = HardwareComma.__new__(HardwareComma)
|
|
hardware.get_modem_state = Mock(side_effect=AssertionError('Wi-Fi must not inspect SIM'))
|
|
with patch('openpilot.common.hardware.comma.hardware.wpa_supplicant_cmd', return_value={}), \
|
|
patch('openpilot.common.hardware.base.HardwareBase.get_network_metered', return_value=False):
|
|
assert hardware.get_network_metered(NetworkType.wifi) is False
|
|
hardware.get_modem_state.assert_not_called()
|
|
|
|
|
|
@pytest.mark.parametrize('provider,iccid,expected', [
|
|
('Webbing', WEBBING_ICCID_PREFIX + '1234', True),
|
|
('Other', WEBBING_ICCID_PREFIX + '1234', False),
|
|
('Webbing', 'other-sim', False),
|
|
])
|
|
def test_comma_profile_still_requires_provider_and_shared_prefix(provider, iccid, expected):
|
|
assert Profile(iccid, '', True, provider).is_comma is expected
|