Skip to content

Commit 5c513a8

Browse files
committed
Initial commit to load username, email, and orcid number into config files.
1 parent 5c3eed7 commit 5c513a8

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/diffpy/labpdfproc/tests/test_tools.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from diffpy.labpdfproc.tools import (
99
known_sources,
1010
load_user_metadata,
11+
load_username_email,
1112
set_input_lists,
1213
set_output_directory,
1314
set_wavelength,
@@ -241,3 +242,47 @@ def test_load_user_metadata_bad(inputs, msg):
241242
actual_args = get_args(cli_inputs)
242243
with pytest.raises(ValueError, match=msg[0]):
243244
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)

src/diffpy/labpdfproc/tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,7 @@ def load_user_metadata(args):
171171
setattr(args, key, value)
172172
delattr(args, "user_metadata")
173173
return args
174+
175+
176+
def load_username_email(args):
177+
pass

0 commit comments

Comments
 (0)