|
8 | 8 | from diffpy.labpdfproc.tools import (
|
9 | 9 | known_sources,
|
10 | 10 | load_user_metadata,
|
| 11 | + load_username_email, |
11 | 12 | set_input_lists,
|
12 | 13 | set_output_directory,
|
13 | 14 | set_wavelength,
|
@@ -241,3 +242,47 @@ def test_load_user_metadata_bad(inputs, msg):
|
241 | 242 | actual_args = get_args(cli_inputs)
|
242 | 243 | with pytest.raises(ValueError, match=msg[0]):
|
243 | 244 | actual_args = load_user_metadata(actual_args)
|
| 245 | + |
| 246 | + |
| 247 | +# Since in both extracting git config or ask users, we take username and email as args. |
| 248 | +# Probably define --username and |
| 249 | +# --email from get_args() |
| 250 | +params7 = [ |
| 251 | + ( |
| 252 | + [ "--username", "stevenhua0320", "--email", "[email protected]", "--orcid", "0009-0003-1947-1857"], |
| 253 | + [[ "username", "stevenhua0320"], [ "email", "[email protected]"], [ "orcid", "0009-0003-1947-1857"]], |
| 254 | + ), |
| 255 | + ( |
| 256 | + [ "--username", "yucongalicechen", "--email", "[email protected]"], |
| 257 | + [[ "username", "yucongalicechen"], [ "email", "[email protected]"]], |
| 258 | + ), |
| 259 | + ( |
| 260 | + [ "--username", "sbillinge", "--email", "[email protected]"], |
| 261 | + [[ "username", "sbillinge"], [ "email", "[email protected]"]], |
| 262 | + ), |
| 263 | +] |
| 264 | + |
| 265 | + |
| 266 | +@pytest.mark.parametrize("inputs, expected", params7) |
| 267 | +def test_load_username_email(inputs, expected): |
| 268 | + actual_args = get_args(inputs) |
| 269 | + # load username, email, orcid(optional)into config in key-value pairs |
| 270 | + actual_args = load_username_email(actual_args) |
| 271 | + assert actual_args == expected |
| 272 | + |
| 273 | + |
| 274 | +params8 = [ |
| 275 | + ( |
| 276 | + [ "--username", "stevenhua0320", "--email", "[email protected]", "--orcid", "ngss-0003-1947-1857"], |
| 277 | + ["Please provide valid orcid number."], |
| 278 | + ), |
| 279 | + ([ "--username", "yucongalicechen%$#", "--email", "[email protected]"], [ "Please provide valid username."]), |
| 280 | + (["--username", "sbllinge", "--email", "sb2896"], ["Please provide valid email."]), |
| 281 | +] |
| 282 | + |
| 283 | + |
| 284 | +@pytest.mark.parametrize("inputs, msg", params8) |
| 285 | +def test_load_username_email_bad(inputs, msg): |
| 286 | + with pytest.raises(ValueError, match=msg[0]): |
| 287 | + actual_args = get_args(inputs) |
| 288 | + actual_args = load_username_email(actual_args) |
0 commit comments