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

Ensure middle name exists when formatting name #325

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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 app/questionnaire/placeholder_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ def list_has_items(list_to_check):
def format_name(first_name, middle_names, last_name, include_middle_names=False):
return (
f"{first_name} {middle_names} {last_name}"
if include_middle_names
if include_middle_names and middle_names
else f"{first_name} {last_name}"
)
7 changes: 7 additions & 0 deletions tests/app/questionnaire/test_placeholder_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ def test_list_has_items(self):
assert not self.transforms.list_has_items([])

def test_format_name(self):
assert self.transforms.format_name("Joe", None, "Bloggs") == "Joe Bloggs"
assert (
self.transforms.format_name(
"Joe", None, "Bloggs", include_middle_names=True
)
== "Joe Bloggs"
)
assert self.transforms.format_name("Joe", "Michael", "Bloggs") == "Joe Bloggs"
assert (
self.transforms.format_name(
Expand Down