@@ -85,7 +85,6 @@ def test_set_wavelength_bad(inputs, msg):
85
85
[["facility=NSLS II" , "beamline=28ID-2" , "favorite color=blue" ]],
86
86
[["facility" , "NSLS II" ], ["beamline" , "28ID-2" ], ["favorite color" , "blue" ]],
87
87
),
88
- ([["facility=NSLS II" , "facility=NSLS III" ]], [["facility" , "NSLS III" ]]),
89
88
([["x=y=z" ]], [["x" , "y=z" ]]),
90
89
]
91
90
@@ -105,16 +104,33 @@ def test_load_user_metadata(inputs, expected):
105
104
106
105
107
106
params6 = [
108
- ([["facility=NSLS" , "II" ]]),
109
- ([["favorite" , "color=blue" ]]),
110
- ([["beamline" , "=" , "28ID-2" ]]),
107
+ (
108
+ [["facility=NSLS" , "II" ]],
109
+ [
110
+ "Please provide key-value pairs in the format key=value. "
111
+ "For more information, use `labpdfproc --help.`"
112
+ ],
113
+ ),
114
+ (
115
+ [["favorite" , "color=blue" ]],
116
+ "Please provide key-value pairs in the format key=value. "
117
+ "For more information, use `labpdfproc --help.`" ,
118
+ ),
119
+ (
120
+ [["beamline" , "=" , "28ID-2" ]],
121
+ "Please provide key-value pairs in the format key=value. "
122
+ "For more information, use `labpdfproc --help.`" ,
123
+ ),
124
+ ([["facility=NSLS II" , "facility=NSLS III" ]], ["Please do not specify repeated keys: facility. " ]),
125
+ ([["wavelength=2" ]], ["Please do not specify repeated keys: wavelength. " ]),
111
126
]
112
127
113
128
114
- @pytest .mark .parametrize ("inputs" , params6 )
115
- def test_load_user_metadata_bad (inputs ):
129
+ @pytest .mark .parametrize ("inputs, msg " , params6 )
130
+ def test_load_user_metadata_bad (inputs , msg ):
116
131
actual_parser = ArgumentParser ()
132
+ actual_parser .add_argument ("--wavelength" )
117
133
actual_parser .add_argument ("--user-metadata" )
118
134
actual_args = actual_parser .parse_args (["--user-metadata" , inputs [0 ]])
119
- with pytest .raises (ValueError ):
135
+ with pytest .raises (ValueError , match = re . escape ( msg [ 0 ]) ):
120
136
actual_args = load_user_metadata (actual_args )
0 commit comments