33
44import pytest
55
6- from techui_builder .builder import Builder
7-
8-
9- @pytest .fixture
10- def gb ():
11- path = Path ("example/bl01t-services/synoptic/create_gui.yaml" )
12- b = Builder (path )
13- b ._services_dir = Path ("./example/bl01t-services/services" )
14- b .setup ()
15- return b
16-
176
187@pytest .mark .parametrize (
198 "attr, expected" ,
209 [
21- ("beamline. dom" , "bl01t" ),
22- ("beamline. desc" , "Test Beamline" ),
10+ ("dom" , "bl01t" ),
11+ ("desc" , "Test Beamline" ),
2312 ],
2413)
25- def test_beamline_attributes (gb : Builder , attr , expected ):
26- assert eval ( f"gb. { attr } " ) == expected
14+ def test_beamline_attributes (builder , attr , expected ):
15+ assert getattr ( builder . beamline , attr ) == expected
2716
2817
2918@pytest .mark .parametrize (
@@ -33,16 +22,16 @@ def test_beamline_attributes(gb: Builder, attr, expected):
3322 (
3423 4 ,
3524 "motor" ,
36- "Hexapod Stage" ,
37- "BL01T-MO-MAP -01" ,
38- "STAGE" ,
25+ "Motor Stage" ,
26+ "BL01T-MO-MOTOR -01" ,
27+ None ,
3928 None ,
4029 None ,
4130 ),
4231 ],
4332)
44- def test_component_attributes (gb : Builder , index , name , desc , P , R , attribute , extras ):
45- component = gb .components [index ]
33+ def test_component_attributes (builder , index , name , desc , P , R , attribute , extras ):
34+ component = builder .components [index ]
4635 assert component .name == name
4736 assert component .desc == desc
4837 assert component .P == P
@@ -56,45 +45,47 @@ def test_component_attributes(gb: Builder, index, name, desc, P, R, attribute, e
5645 "index, type, desc, P, M, R" ,
5746 [
5847 (0 , "pmac.GeoBrick" , None , "BL01T-MO-BRICK-01" , None , None ),
59- (0 , "pmac.autohome" , None , "BL01T-MO-MAP -01:STAGE " , None , None ),
48+ (0 , "pmac.autohome" , None , "BL01T-MO-MOTOR -01" , None , None ),
6049 (
6150 1 ,
6251 "pmac.dls_pmac_asyn_motor" ,
6352 None ,
64- "BL01T-MO-MAP -01:STAGE " ,
53+ "BL01T-MO-MOTOR -01" ,
6554 "X" ,
6655 None ,
6756 ),
6857 (
6958 2 ,
7059 "pmac.dls_pmac_asyn_motor" ,
7160 None ,
72- "BL01T-MO-MAP -01:STAGE " ,
61+ "BL01T-MO-MOTOR -01" ,
7362 "A" ,
7463 None ,
7564 ),
7665 ],
7766)
78- def test_gb_extract_entities (gb : Builder , index , type , desc , P , M , R ):
79- entity = gb .entities [P ][index ]
67+ def test_gb_extract_entities (builder , index , type , desc , P , M , R ):
68+ builder ._extract_entities (
69+ builder ._services_dir .joinpath ("bl01t-mo-ioc-01/config/ioc.yaml" )
70+ )
71+ entity = builder .entities [P ][index ]
8072 assert entity .type == type
8173 assert entity .desc == desc
8274 assert entity .P == P
8375 assert entity .M == M
8476 assert entity .R == R
8577
8678
87- def test_setup (gb : Builder ):
88- gb ._services_dir = Path (f"example/{ gb .beamline .dom } -services/services" )
89- gb ._write_directory = Path ("example/data" )
90- gb .generate_screens ()
79+ def test_generate_screens (builder ):
80+ builder .setup ()
81+ builder .generate_screens ()
9182
92- with open (f"./ { gb ._write_directory } /motor.bob" ) as f :
83+ with open (f"{ builder ._write_directory } /motor.bob" ) as f :
9384 expected = f .read ()
9485
95- with open ("./ tests/test_files/motor.bob" ) as f :
86+ with open ("tests/test_files/motor.bob" ) as f :
9687 control = f .read ()
9788
9889 assert expected == control
99- if Path .exists (Path (f"./ { gb ._write_directory } /motor.bob" )):
100- os .remove (f"./ { gb ._write_directory } /motor.bob" )
90+ if Path .exists (Path (f"{ builder ._write_directory } /motor.bob" )):
91+ os .remove (f"{ builder ._write_directory } /motor.bob" )
0 commit comments