diff --git a/docassemble/AssemblyLine/al_general.py b/docassemble/AssemblyLine/al_general.py index a9076471..ea76a8ab 100644 --- a/docassemble/AssemblyLine/al_general.py +++ b/docassemble/AssemblyLine/al_general.py @@ -1672,6 +1672,36 @@ def pronoun_subjective(self, **kwargs) -> str: return capitalize(output) return output + def name_full(self) -> str: + """Returns the individual's full name. + + Returns: + str: The individual's full name. + """ + return self.name.full(middle="full") + + def name_initials(self) -> str: + """ + Returns the individual's name with the middle name as an initial. + Equivalent to `name.full(middle="initial")`, which is also the default. + Defined only to make it possible to be explicit about the name form. + + Returns: + str: The individual's name with the middle name as an initial. + """ + return self.name.full(middle="initial") + + def name_short(self) -> str: + """ + Returns the individual's name without any middle name. + + Equivalent to self.name.firstlast() + + Returns: + str: The individual' + """ + return self.name.firstlast() + # (DANav isn't in public DA API, but currently in functions.py) def section_links(nav) -> List[str]: # type: ignore diff --git a/docassemble/AssemblyLine/test_al_general.py b/docassemble/AssemblyLine/test_al_general.py index 26eca1c3..d2bd1e7e 100644 --- a/docassemble/AssemblyLine/test_al_general.py +++ b/docassemble/AssemblyLine/test_al_general.py @@ -427,6 +427,15 @@ def test_custom_pronouns(self): with self.assertRaises(DAAttributeError): self.individual.pronoun_objective() + def test_name_methods(self): + self.individual.name.first = "John" + self.individual.name.middle = "Jacob" + self.individual.name.last = "Jingleheimer" + + self.assertEqual(self.individual.name_full(), "John Jacob Jingleheimer") + self.assertEqual(self.individual.name_initials(), "John J. Jingleheimer") + self.assertEqual(self.individual.name_short(), "John Jingleheimer") + class test_get_visible_al_nav_items(unittest.TestCase): def test_case_1(self):