This commit is contained in:
@@ -15,12 +15,12 @@ from unittest.mock import patch
|
||||
("furka", "athos")
|
||||
])
|
||||
def test_get_beamline(instrument, expected_beamline):
|
||||
"""Test the beamline retrieval for a given instrument."""
|
||||
# Test the beamline retrieval for a given instrument
|
||||
beamline = get_beamline(instrument)
|
||||
assert beamline == expected_beamline, f"Expected {expected_beamline}, but got {beamline}"
|
||||
|
||||
def test_get_pvname_reprate_for_inferred_beamline():
|
||||
"""Test the PV name retrieval when using inferred beamline based on IP address."""
|
||||
# Test the PV name retrieval when using inferred beamline based on IP address
|
||||
with patch("socket.gethostname", return_value="testhost"), patch("socket.gethostbyname", return_value="129.129.242"):
|
||||
beamline = infer_beamline() # This will return "alvra" based on the IP
|
||||
pvname = get_pvname_reprate(instrument=None, beamline=beamline) # This should return the PV name associated with 'aramis'
|
||||
@@ -37,7 +37,7 @@ def test_get_pvname_reprate_for_inferred_beamline():
|
||||
("129.129.247", "furka")
|
||||
])
|
||||
def test_infer_beamline_from_ip(ip, expected_instrument):
|
||||
"""Test that the beamline is correctly inferred based on the IP address."""
|
||||
# Test that the beamline is correctly inferred based on the IP address
|
||||
# Mock the socket functions to simulate an IP address
|
||||
with patch("socket.gethostname", return_value="testhost"), patch("socket.gethostbyname", return_value=ip):
|
||||
instrument = infer_beamline()
|
||||
@@ -52,12 +52,12 @@ def test_infer_beamline_from_ip(ip, expected_instrument):
|
||||
("furka", "athos", "SIN-TIMAST-TMA:Bunch-2-Exp-Freq-RB")
|
||||
])
|
||||
def test_get_pvname_reprate_with_instrument_and_beamline(instrument, beamline, pvname):
|
||||
"""Test that the PV name is correctly retrieved based on instrument and beamline."""
|
||||
# Test that the PV name is correctly retrieved based on instrument and beamline
|
||||
retrieved_pvname = get_pvname_reprate(instrument, beamline)
|
||||
assert retrieved_pvname == pvname, f"Expected {pvname}, but got {retrieved_pvname}"
|
||||
|
||||
def test_invalid_instrument_or_beamline():
|
||||
"""Test that None is returned when an invalid instrument or beamline is provided."""
|
||||
# Test that None is returned when an invalid instrument or beamline is provided
|
||||
# Invalid instrument
|
||||
monitor = RepRateMonitor(target="invalid_instrument")
|
||||
assert monitor.name is None, f"Expected None, but got {monitor.name}"
|
||||
@@ -67,7 +67,7 @@ def test_invalid_instrument_or_beamline():
|
||||
assert monitor.name is None, f"Expected None, but got {monitor.name}"
|
||||
|
||||
def test_monitor_value_update():
|
||||
#Test that the RepRateMonitor correctly updates its value and units
|
||||
# Test that the RepRateMonitor correctly updates its value and units
|
||||
monitor = RepRateMonitor("alvra") # Example instrument
|
||||
# Check that the initial value is 20.0 and the units are correct
|
||||
assert monitor.value == 20.0, f"Expected 20.0, but got {monitor.value}"
|
||||
|
||||
Reference in New Issue
Block a user