Skip to content

Commit 42fa364

Browse files
fix: add tests for orcid
1 parent c246b2a commit 42fa364

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

tests/test_tools.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,27 @@ def test_load_user_metadata_bad(inputs, expected_error_msg):
316316

317317
@pytest.mark.parametrize(
318318
"inputs, expected",
319-
[
320-
([None, None], ["home_username", "[email protected]"]),
321-
(["cli_username", None], ["cli_username", "[email protected]"]),
322-
([None, "[email protected]"], ["home_username", "[email protected]"]),
323-
(["cli_username", "[email protected]"], ["cli_username", "[email protected]"]),
319+
[ # Test that when cli inputs are present, they override home config, otherwise we take home config
320+
(
321+
{"username": None, "email": None, "orcid": None},
322+
{"username": "home_username", "email": "[email protected]", "orcid": "home_orcid"},
323+
),
324+
(
325+
{"username": "cli_username", "email": None, "orcid": None},
326+
{"username": "cli_username", "email": "[email protected]", "orcid": "home_orcid"},
327+
),
328+
(
329+
{"username": None, "email": "[email protected]", "orcid": None},
330+
{"username": "home_username", "email": "[email protected]", "orcid": "home_orcid"},
331+
),
332+
(
333+
{"username": None, "email": None, "orcid": "cli_orcid"},
334+
{"username": "home_username", "email": "[email protected]", "orcid": "cli_orcid"},
335+
),
336+
(
337+
{"username": "cli_username", "email": "[email protected]", "orcid": "cli_orcid"},
338+
{"username": "cli_username", "email": "[email protected]", "orcid": "cli_orcid"},
339+
),
324340
],
325341
)
326342
def test_load_user_info(monkeypatch, inputs, expected, user_filesystem):
@@ -329,12 +345,21 @@ def test_load_user_info(monkeypatch, inputs, expected, user_filesystem):
329345
monkeypatch.setattr("pathlib.Path.home", lambda _: home_dir)
330346
os.chdir(cwd)
331347

332-
expected_username, expected_email = expected
333-
cli_inputs = ["2.5", "data.xy", "--username", inputs[0], "--email", inputs[1]]
348+
cli_inputs = [
349+
"2.5",
350+
"data.xy",
351+
"--username",
352+
inputs["username"],
353+
"--email",
354+
inputs["email"],
355+
"--orcid",
356+
inputs["orcid"],
357+
]
334358
actual_args = get_args(cli_inputs)
335359
actual_args = load_user_info(actual_args)
336-
assert actual_args.username == expected_username
337-
assert actual_args.email == expected_email
360+
assert actual_args.username == expected["username"]
361+
assert actual_args.email == expected["email"]
362+
assert actual_args.orcid == expected["orcid"]
338363

339364

340365
def test_load_package_info(mocker):

0 commit comments

Comments
 (0)