Skip to content
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

creating person #36

Merged
merged 6 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bids2openminds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create_openminds_person(full_name):
family_name = person.last

if person.middle:
alternate_names.append(person.full_name)
given_name = f"{given_name} {person.middle}"

if person.nickname:
alternate_names.append(person.nickname)
Expand Down
22 changes: 22 additions & 0 deletions test/test_person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# test for create_openminds_person function in the main
import pytest
from bids2openminds.main import create_openminds_person
import openminds.latest.core as omcore

# Test data: (full_name, given_name, family_name)
example_names = [("John Ronald Reuel Tolkien", "John Ronald Reuel", "Tolkien"),
("Bilbo Baggins", "Bilbo", "Baggins")]


@pytest.mark.parametrize("full_name,given_name,family_name", example_names)
def test_create_openminds_person(full_name, given_name, family_name):
openminds_person_object = omcore.Person(given_name=given_name,
family_name=family_name)
bids2openminds_person_object = create_openminds_person(full_name)
assert openminds_person_object.given_name == bids2openminds_person_object.given_name, \
f"Given names don't match for input '{full_name}'"
assert openminds_person_object.family_name == bids2openminds_person_object.family_name, \
f"Family names don't match for input '{full_name}'"
assert openminds_person_object.type_ == bids2openminds_person_object.type_, \
f"Person types don't match for input '{full_name}'"
# assert openminds_person_object == bids2openminds_person_object