1
- from typing import get_args , get_origin
2
-
3
1
import pytest
4
2
from bluesky import RunEngine
5
- from dodal .devices .electron_analyser import ElectronAnalyserDetectorImpl
3
+ from dodal .beamlines import b07 , i09
4
+ from dodal .devices .electron_analyser import ElectronAnalyserDetector
6
5
from dodal .devices .electron_analyser .specs import SpecsDetector
7
6
from dodal .devices .electron_analyser .vgscienta import VGScientaDetector
7
+ from dodal .testing .electron_analyser import create_detector
8
8
from ophyd_async .core import SignalR , init_devices
9
9
from ophyd_async .sim import SimMotor
10
10
11
- from tests .electron_analyser .util import TEST_SPECS_SEQUENCE , TEST_VGSCIENTA_SEQUENCE
11
+ from tests .electron_analyser .util import (
12
+ TEST_SPECS_SEQUENCE ,
13
+ TEST_VGSCIENTA_SEQUENCE ,
14
+ )
12
15
13
16
14
17
@pytest .fixture
@@ -28,30 +31,28 @@ async def energy_sources(
28
31
return {"source1" : dcm_energy .user_readback , "source2" : pgm_energy .user_readback }
29
32
30
33
31
- @pytest .fixture
34
+ @pytest .fixture (
35
+ params = [
36
+ VGScientaDetector [i09 .LensMode , i09 .PsuMode , i09 .PassEnergy ],
37
+ SpecsDetector [b07 .LensMode , b07 .PsuMode ],
38
+ ]
39
+ )
32
40
async def sim_analyser (
33
- detector_class : type [ ElectronAnalyserDetectorImpl ] ,
41
+ request : pytest . FixtureRequest ,
34
42
energy_sources : dict [str , SignalR [float ]],
35
43
RE : RunEngine ,
36
- ) -> ElectronAnalyserDetectorImpl :
37
- # ToDo - this needs to use what dodal uses once this is implemented
38
- # https://github.com/DiamondLightSource/dodal/issues/1396
39
- parameters = {
40
- "prefix" : "TEST:" ,
41
- "lens_mode_type" : get_args (detector_class )[0 ],
42
- "psu_mode_type" : get_args (detector_class )[1 ],
43
- "energy_sources" : energy_sources ,
44
- }
45
- if get_origin (detector_class ) is VGScientaDetector :
46
- parameters ["pass_energy_type" ] = get_args (detector_class )[2 ]
47
-
48
- async with init_devices (mock = True , connect = True ):
49
- sim_detector = detector_class (** parameters )
50
- return sim_detector
44
+ ) -> ElectronAnalyserDetector :
45
+ with init_devices (mock = True ):
46
+ sim_analyser = await create_detector (
47
+ request .param ,
48
+ prefix = "TEST:" ,
49
+ energy_sources = energy_sources ,
50
+ )
51
+ return sim_analyser
51
52
52
53
53
54
@pytest .fixture
54
- def sequence_file (sim_analyser : ElectronAnalyserDetectorImpl ) -> str :
55
+ def sequence_file (sim_analyser : ElectronAnalyserDetector ) -> str :
55
56
if isinstance (sim_analyser , VGScientaDetector ):
56
57
return TEST_VGSCIENTA_SEQUENCE
57
58
elif isinstance (sim_analyser , SpecsDetector ):
0 commit comments