Skip to content

Commit eec4a53

Browse files
committed
Split up disable_emittance flag tests
Now that disabling emittance on an existing ATSimulator isnt supported, it makes more sense to have two seperate tests one which tests a simulator with and one without emittance disabled. Rather than testing both at once
1 parent 48f0e7d commit eec4a53

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tests/test_at_simulator_object.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,25 @@ def test_recalculate_phys_data(atsim, initial_phys_data):
169169
numpy.testing.assert_almost_equal(emit, [1.34308653e-10, 3.74339964e-13], decimal=3)
170170

171171

172-
def test_emittance_flag(atsim, initial_phys_data):
172+
def test_ohmi_envelope_with_emittance_enabled(atsim, initial_phys_data):
173173
# Check emittance data is intially there
174-
assert atsim._sim_params.emittance
175174
assert len(atsim._lattice_data.emittance) == 3
175+
assert atsim._sim_params.emittance
176176
# Check that ohmi_envelope is called when emittance is True
177177
atsim._at_lat.ohmi_envelope = mock.Mock()
178178
atsim.trigger_calculation()
179179
cothread.Sleep(0.1)
180180
atsim._at_lat.ohmi_envelope.assert_called_once()
181-
# Check that ohmi_envelope isn't called when emittance is False and that
182-
# there isn't any emittance data
183-
atsim._sim_params.emittance = False
184-
atsim._at_lat.ohmi_envelope.reset_mock()
181+
182+
183+
def test_ohmi_envelope_with_emittance_disabled(atsim, initial_phys_data):
184+
atsim._sim_params = atip.simulator.SimParams(emittance=False)
185+
assert not atsim._sim_params.emittance
186+
atsim._at_lat.ohmi_envelope = mock.Mock()
185187
atsim.trigger_calculation()
186188
cothread.Sleep(0.1)
189+
# Check that ohmi_envelope isn't called when emittance is False and that
190+
# there isn't any emittance data
187191
atsim._at_lat.ohmi_envelope.assert_not_called()
188192
assert len(atsim._lattice_data.emittance) == 0
189193

@@ -323,7 +327,12 @@ def test_get_emittance(mocked_atsim):
323327
assert mocked_atsim.get_emittance("y") == 0.45
324328
with pytest.raises(FieldException):
325329
mocked_atsim.get_emittance("not_a_field")
326-
mocked_atsim._sim_params.emittance = False
330+
331+
332+
def test_get_emittance_with_emittance_disabled(mocked_atsim):
333+
assert mocked_atsim._sim_params.emittance
334+
mocked_atsim._sim_params = atip.simulator.SimParams(emittance=False)
335+
assert not mocked_atsim._sim_params.emittance
327336
with pytest.raises(DataSourceException):
328337
mocked_atsim.get_emittance()
329338

0 commit comments

Comments
 (0)