Skip to content

Commit

Permalink
Add tests for new lines in Lakeshore475.py
Browse files Browse the repository at this point in the history
  • Loading branch information
scasagrande committed Sep 11, 2020
1 parent 01ee79d commit 13f7596
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions instruments/tests/test_lakeshore/test_lakeshore475.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ def test_lakeshore475_field_setpoint():
lsh.field_setpoint = 23.


def test_lakeshore475_field_setpoint_wrong_units():
"""
Setting the field setpoint with the wrong units
"""
with expected_protocol(
ik.lakeshore.Lakeshore475,
[
"UNIT?",
],
[
"1"
],
) as lsh:
with pytest.raises(ValueError) as exc_info:
lsh.field_setpoint = u.Quantity(1., u.tesla)
exc_msg = exc_info.value.args[0]
assert "Field setpoint must be specified in the same units" in exc_msg


def test_lakeshore475_field_get_control_params():
"""
Get field control parameters.
Expand Down Expand Up @@ -230,10 +249,8 @@ def test_lakeshore475_field_set_control_params_not_a_tuple():
"""
with expected_protocol(
ik.lakeshore.Lakeshore475,
[
],
[
],
[],
[],
) as lsh:
with pytest.raises(TypeError) as exc_info:
lsh.field_control_params = 42
Expand All @@ -242,6 +259,30 @@ def test_lakeshore475_field_set_control_params_not_a_tuple():
" a tuple"


def test_lakeshore475_field_set_control_params_wrong_units():
"""
Set field control parameters with the wrong units
"""
with expected_protocol(
ik.lakeshore.Lakeshore475,
[
"UNIT?",
],
[
"1", # gauss
],
) as lsh:
with pytest.raises(ValueError) as exc_info:
lsh.field_control_params = (
5.0,
50.0,
u.Quantity(120.0, u.tesla / u.min),
u.Quantity(60.0, u.volt / u.min)
)
exc_msg = exc_info.value.args[0]
assert "Field control params ramp rate must be specified in the same units" in exc_msg


def test_lakeshore475_p_value():
"""
Get / set p-value.
Expand Down

0 comments on commit 13f7596

Please sign in to comment.