ecu-tests/tests/unit/test_babylin_adapter_mocked.py

23 lines
587 B
Python

import pytest
from ecu_framework.lin.babylin import BabyLinInterface
from vendor import mock_babylin_wrapper as mock_bl
class _ErrMock:
@staticmethod
def create_BabyLIN():
bl = mock_bl.create_BabyLIN()
# Force loadSDF to return a non-OK code
def fail_load(*args, **kwargs):
return 1 # non BL_OK
bl.BLC_loadSDF = fail_load
return bl
@pytest.mark.unit
def test_connect_sdf_error_raises():
lin = BabyLinInterface(sdf_path="dummy.sdf", wrapper_module=_ErrMock)
with pytest.raises(RuntimeError):
lin.connect()