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
33 lines
888 B
Python
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")
|