import os from unittest.mock import patch import pytest from aarecommon.config.beamline import mx_beamline from aarecommon.models.beamline import MXBeamline def test_mx_beamline_default(): with patch.dict(os.environ, {}, clear=True): with pytest.raises(ValueError) as e: # If BEAMLINE is not set, it should raise mx_beamline() assert e.match("set the BEAMLINE") def test_mx_beamline_x10sa(): with patch.dict(os.environ, {"BEAMLINE": "x10sa"}): assert mx_beamline() == MXBeamline.X10SA def test_mx_beamline_x06sa(): with patch.dict(os.environ, {"BEAMLINE": "X06SA "}): assert mx_beamline() == MXBeamline.X06SA def test_mx_beamline_invalid(): with pytest.raises(ValueError) as e: with patch.dict(os.environ, {"BEAMLINE": "INVALID"}): mx_beamline() assert e.match("not a valid value")