All checks were successful
Test pipeline / test (push) Successful in 14s
Remove Phase class, organizational metadata blocks, and unused project fields. Update configuration to use 'default_grants' and simplify PI usage to fallback corresponding author determination only. BREAKING CHANGES: - Remove 'phase' and 'project' fields from configuration - Use 'default_grants' instead of 'default_grant' - Generate only standard Dataverse citation metadata
92 lines
2.6 KiB
Python
92 lines
2.6 KiB
Python
from doi2dataset import Institution, Person
|
|
|
|
|
|
def test_person_to_dict_with_string_affiliation():
|
|
"""Test Person.to_dict() with a string affiliation."""
|
|
person = Person(
|
|
family_name="Doe",
|
|
given_name="John",
|
|
orcid="0000-0001-2345-6789",
|
|
email="john.doe@example.org",
|
|
affiliation="Test University"
|
|
)
|
|
|
|
result = person.to_dict()
|
|
|
|
assert result["family_name"] == "Doe"
|
|
assert result["given_name"] == "John"
|
|
assert result["orcid"] == "0000-0001-2345-6789"
|
|
assert result["email"] == "john.doe@example.org"
|
|
assert result["affiliation"] == "Test University"
|
|
|
|
|
|
def test_person_to_dict_with_institution_ror():
|
|
"""Test Person.to_dict() with an Institution that has a ROR ID."""
|
|
inst = Institution("Test University", "https://ror.org/12345")
|
|
|
|
person = Person(
|
|
family_name="Doe",
|
|
given_name="John",
|
|
orcid="0000-0001-2345-6789",
|
|
email="john.doe@example.org",
|
|
affiliation=inst
|
|
)
|
|
|
|
result = person.to_dict()
|
|
|
|
assert result["affiliation"] == "https://ror.org/12345"
|
|
# Check other fields too
|
|
assert result["family_name"] == "Doe"
|
|
assert result["given_name"] == "John"
|
|
|
|
|
|
def test_person_to_dict_with_institution_display_name_only():
|
|
"""Test Person.to_dict() with an Institution that has only a display_name."""
|
|
inst = Institution("Test University") # No ROR ID
|
|
|
|
person = Person(
|
|
family_name="Smith",
|
|
given_name="Jane",
|
|
orcid="0000-0001-9876-5432",
|
|
affiliation=inst
|
|
)
|
|
|
|
result = person.to_dict()
|
|
|
|
assert result["affiliation"] == "Test University"
|
|
assert result["family_name"] == "Smith"
|
|
assert result["given_name"] == "Jane"
|
|
|
|
|
|
def test_person_to_dict_with_empty_institution():
|
|
"""Test Person.to_dict() with an Institution that has neither ROR nor display_name."""
|
|
# Create an Institution with empty values
|
|
inst = Institution("")
|
|
|
|
person = Person(
|
|
family_name="Brown",
|
|
given_name="Robert",
|
|
affiliation=inst
|
|
)
|
|
|
|
result = person.to_dict()
|
|
|
|
assert result["affiliation"] == ""
|
|
assert result["family_name"] == "Brown"
|
|
assert result["given_name"] == "Robert"
|
|
|
|
|
|
def test_person_to_dict_with_no_affiliation():
|
|
"""Test Person.to_dict() with no affiliation."""
|
|
person = Person(
|
|
family_name="Green",
|
|
given_name="Alice",
|
|
orcid="0000-0002-1111-2222"
|
|
)
|
|
|
|
result = person.to_dict()
|
|
|
|
assert result["affiliation"] == ""
|
|
assert result["family_name"] == "Green"
|
|
assert result["given_name"] == "Alice"
|
|
assert result["orcid"] == "0000-0002-1111-2222"
|