-
Notifications
You must be signed in to change notification settings - Fork 11
load username, email, and orcid number into config files #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from diffpy.labpdfproc.tools import ( | ||
known_sources, | ||
load_user_metadata, | ||
load_username_email, | ||
set_input_lists, | ||
set_output_directory, | ||
set_wavelength, | ||
|
@@ -241,3 +242,47 @@ def test_load_user_metadata_bad(inputs, msg): | |
actual_args = get_args(cli_inputs) | ||
with pytest.raises(ValueError, match=msg[0]): | ||
actual_args = load_user_metadata(actual_args) | ||
|
||
|
||
# Since in both extracting git config or ask users, we take username and email as args. | ||
# Probably define --username and | ||
# --email from get_args() | ||
params7 = [ | ||
( | ||
["--username", "stevenhua0320", "--email", "[email protected]", "--orcid", "0009-0003-1947-1857"], | ||
[["username", "stevenhua0320"], ["email", "[email protected]"], ["orcid", "0009-0003-1947-1857"]], | ||
), | ||
( | ||
["--username", "yucongalicechen", "--email", "[email protected]"], | ||
[["username", "yucongalicechen"], ["email", "[email protected]"]], | ||
), | ||
( | ||
["--username", "sbillinge", "--email", "[email protected]"], | ||
[["username", "sbillinge"], ["email", "[email protected]"]], | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("inputs, expected", params7) | ||
def test_load_username_email(inputs, expected): | ||
actual_args = get_args(inputs) | ||
# load username, email, orcid(optional)into config in key-value pairs | ||
actual_args = load_username_email(actual_args) | ||
assert actual_args == expected | ||
|
||
|
||
params8 = [ | ||
( | ||
["--username", "stevenhua0320", "--email", "[email protected]", "--orcid", "ngss-0003-1947-1857"], | ||
["Please provide valid orcid number."], | ||
), | ||
(["--username", "yucongalicechen%$#", "--email", "[email protected]"], ["Please provide valid username."]), | ||
(["--username", "sbllinge", "--email", "sb2896"], ["Please provide valid email."]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo? Also, I don't think we need this check. The user can put pretty much anything they want for username. We may want to check if an email is valid it is better to use non-identifying information for the tests, no actual emails and names. We often use names in the tests that convey meaning about the test, for example, "bad_email" (no @) "[email protected]" for example. |
||
] | ||
|
||
|
||
@pytest.mark.parametrize("inputs, msg", params8) | ||
def test_load_username_email_bad(inputs, msg): | ||
with pytest.raises(ValueError, match=msg[0]): | ||
actual_args = get_args(inputs) | ||
actual_args = load_username_email(actual_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not quite correct. your expected is a list of lists, but it should be args attributes.