Repository: nfdi4cat/voc4cat-tool (language: python)

Issue:
github username with uppercase are not accepted in idrange-file
The validation is too strict. It turns out that GitHub usernames may include uppercase letters (https://github.com/nfdi4cat/voc4cat/pull/41); the usernames are however case-insensitive in comparisons. We need to adapt the regex for validation.


Discussion / hints:

Fix patch:
diff --git a/LICENSE b/LICENSE
index e99d8f0..61f9813 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
 Copyright (c) 2021-2023 RDFLib VocExcel Team
-Copyright (c) 2022-2023 NFDI4Cat Voc4Cat Team
+Copyright (c) 2022-2024 NFDI4Cat Voc4Cat Team
 
 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
diff --git a/src/voc4cat/config.py b/src/voc4cat/config.py
index 0f7d283..85278dc 100644
--- a/src/voc4cat/config.py
+++ b/src/voc4cat/config.py
@@ -42,7 +42,7 @@ class Checks(BaseModel):
 class IdrangeItem(BaseModel):
     first_id: conint(ge=1)
     last_id: int
-    gh_name: constr(regex=r"(^(^$)|([a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$))") = ""
+    gh_name: constr(regex=r"(^(^$)|[a-zA-Z0-9](?:-?[a-zA-Z0-9]){0,38})$") = ""
     orcid: Orcid | None = None
     ror_id: Ror | None = None
 


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index cea5b5b..243264d 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -96,3 +96,19 @@ def test_idrange_item_validation(datadir, temp_config):
     assert "ID range requires a GitHub name or an ORCID (range: 1-2)." in str(
         excinfo.value
     )
+
+
+@pytest.mark.parametrize("gh_name", ["nobody", "NoBody", "no-body", "nobody-02"])
+def test_gh_name_valid(temp_config, gh_name):
+    """Test valid github names (issue193)"""
+    config = temp_config
+    ri = config.IdrangeItem(first_id=1, last_id=2, gh_name=gh_name)
+    assert ri.gh_name == gh_name
+
+
+@pytest.mark.parametrize("gh_name", ["", "-02"])
+def test_gh_name_invalid(temp_config, gh_name):
+    """Test invalid github names (issue193)"""
+    config = temp_config
+    with pytest.raises(ValidationError):
+        config.IdrangeItem(first_id=1, last_id=2, gh_name=gh_name)