Files
AareCommon/tests/test_beamline.py
T
perl_d 3764c987b0
CI / lint (pull_request) Successful in 20s
CI / test (3.11) (pull_request) Successful in 25s
CI / test (3.12) (pull_request) Successful in 25s
CI / test (3.13) (pull_request) Successful in 30s
CI / lint (push) Successful in 18s
Build and Publish / release (push) Successful in 19s
CI / test (3.12) (push) Successful in 24s
CI / test (3.11) (push) Successful in 33s
CI / test (3.13) (push) Successful in 27s
test: update test for env var
2026-07-08 11:48:46 +02:00

33 lines
888 B
Python

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")