@@ -198,9 +198,7 @@ def test_set_output_directory_bad(user_filesystem):
198198@pytest .mark .parametrize (
199199 "inputs, expected" ,
200200 [
201- # C1: nothing passed in, expect default is Mo
202- ([], {"wavelength" : 0.71073 , "anode_type" : "Mo" }),
203- # C2: only a valid anode type was entered (case independent),
201+ # C1: only a valid anode type was entered (case independent),
204202 # expect to match the corresponding wavelength
205203 # and preserve the correct case anode type
206204 (["--anode-type" , "Mo" ], {"wavelength" : 0.71073 , "anode_type" : "Mo" }),
@@ -239,45 +237,51 @@ def test_set_output_directory_bad(user_filesystem):
239237 ["--anode-type" , "cuka1" ],
240238 {"wavelength" : 1.54056 , "anode_type" : "CuKa1" },
241239 ),
242- # C3: only a valid wavelength was entered,
240+ # C2: a valid wavelength was entered,
243241 # expect to include the wavelength only and anode type is None
244242 (["--wavelength" , "0.25" ], {"wavelength" : 0.25 , "anode_type" : None }),
245- # C4: both valid anode type and wavelength were entered,
246- # expect to remove the anode type and preserve wavelength only
247- (
248- ["--wavelength" , "0.25" , "--anode-type" , "Ag" ],
249- {"wavelength" : 0.25 , "anode_type" : None },
250- ),
243+ # C3: nothing passed in, but mu*D was provided and xtype is on tth
244+ # expect wavelength and anode type to be None
245+ # and program proceeds without error
246+ ([], {"wavelength" : None , "anode_type" : None }),
251247 ],
252248)
253249def test_set_wavelength (inputs , expected ):
254250 cli_inputs = ["2.5" , "data.xy" ] + inputs
255251 actual_args = get_args (cli_inputs )
256252 actual_args = set_wavelength (actual_args )
257253 assert actual_args .wavelength == expected ["wavelength" ]
258- assert getattr ( actual_args , " anode_type" , None ) == expected ["anode_type" ]
254+ assert actual_args . anode_type == expected ["anode_type" ]
259255
260256
261257@pytest .mark .parametrize (
262258 "inputs, expected_error_msg" ,
263259 [
264- (
260+ ( # C1.1: nothing passed in, xtype is not on tth
261+ # expect error asking for either wavelength or anode type
262+ ["--xtype" , "q" ],
263+ f"Please provide a wavelength or anode type. "
264+ f"Allowed anode types are { * known_sources , } ." ,
265+ ),
266+ # C1.2: nothing passed in, need to look up mu*D
267+ # expect error asking for either wavelength or anode type
268+ ( # C2: both wavelength and anode type were specified
269+ # expect error asking not to specify both
270+ ["--wavelength" , "0.7" , "--anode-type" , "Mo" ],
271+ f"Please provide either a wavelength or an anode type, not both. "
272+ f"Allowed anode types are { * known_sources , } ." ,
273+ ),
274+ ( # C3: invalid anode type
265275 ["--anode-type" , "invalid" ],
266276 f"Anode type not recognized. "
267277 f"Please rerun specifying an anode_type from { * known_sources , } ." ,
268278 ),
269- (
279+ ( # C4: invalid wavelength
270280 ["--wavelength" , "0" ],
271281 "No valid wavelength. "
272282 "Please rerun specifying a known anode_type "
273283 "or a positive wavelength." ,
274284 ),
275- (
276- ["--wavelength" , "-1" , "--anode-type" , "Mo" ],
277- "No valid wavelength. "
278- "Please rerun specifying a known anode_type "
279- "or a positive wavelength." ,
280- ),
281285 ],
282286)
283287def test_set_wavelength_bad (inputs , expected_error_msg ):
@@ -515,6 +519,8 @@ def test_load_metadata(mocker, user_filesystem):
515519 cli_inputs = [
516520 "2.5" ,
517521 "." ,
522+ "--anode-type" ,
523+ "Mo" ,
518524 "--user-metadata" ,
519525 "key=value" ,
520526 "--username" ,
0 commit comments