From 90fcd70bc6c60751d6af5a887118e5921f46f056 Mon Sep 17 00:00:00 2001 From: Sven van der Burg Date: Mon, 9 Aug 2021 14:12:36 +0200 Subject: [PATCH] Use 3-arg click callback for validate_orcid_id --- nanopub/setup_nanopub_profile.py | 5 +++-- tests/test_setup_profile.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nanopub/setup_nanopub_profile.py b/nanopub/setup_nanopub_profile.py index 6c983600..93b6750f 100755 --- a/nanopub/setup_nanopub_profile.py +++ b/nanopub/setup_nanopub_profile.py @@ -21,10 +21,11 @@ ORCID_ID_REGEX = r'^https://orcid.org/(\d{4}-){3}\d{3}(\d|X)$' -def validate_orcid_id(ctx, orcid_id: str): +def validate_orcid_id(ctx, param, orcid_id: str): """ Check if valid ORCID iD, should be https://orcid.org/ + 16 digit in form: - https://orcid.org/0000-0000-0000-0000 + https://orcid.org/0000-0000-0000-0000. ctx and param are + necessary `click` callback arguments """ if re.match(ORCID_ID_REGEX, orcid_id): return orcid_id diff --git a/tests/test_setup_profile.py b/tests/test_setup_profile.py index 7b1998fe..34ad3cc5 100644 --- a/tests/test_setup_profile.py +++ b/tests/test_setup_profile.py @@ -103,7 +103,7 @@ def test_validate_orcid_id(): valid_ids = ['https://orcid.org/1234-5678-1234-5678', 'https://orcid.org/1234-5678-1234-567X'] for orcid_id in valid_ids: - assert validate_orcid_id(ctx=None, orcid_id=orcid_id) == orcid_id + assert validate_orcid_id(ctx=None, param=None, orcid_id=orcid_id) == orcid_id invalid_ids = ['https://orcid.org/abcd-efgh-abcd-efgh', 'https://orcid.org/1234-5678-1234-567', @@ -112,4 +112,4 @@ def test_validate_orcid_id(): '0000-0000-0000-0000'] for orcid_id in invalid_ids: with pytest.raises(ValueError): - validate_orcid_id(ctx=None, orcid_id=orcid_id) + validate_orcid_id(ctx=None, param=None, orcid_id=orcid_id)