本文整理汇总了Python中models.Person.descendence方法的典型用法代码示例。如果您正苦于以下问题:Python Person.descendence方法的具体用法?Python Person.descendence怎么用?Python Person.descendence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.descendence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PersonTest
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import descendence [as 别名]
#.........这里部分代码省略.........
self.other_son.born_in = self.d
self.other_son.family = self.ff
self.other_son.save()
def test_family_leader_patriarchal(self):
"""
Must return the correct family leader based patriarchal configured
leadership.
"""
self.son.family = self.ff
self.assertEqual(self.son.family_leader(), self.father)
def test_family_leader_matriarchal(self):
"""
Must return the correct family leader based matriarchal configured
leadership.
"""
self.son.family = self.mf
self.assertEqual(self.son.family_leader(), self.mother)
def test_family_leader_not_defined(self):
"""
Must return a None object when the leadership is not defined.
"""
self.son.family = self.mf
self.son.family.leadership = None
self.assertIsNone(self.son.family_leader())
def test_is_alive_not_defined(self):
"""
Tests the return value when a Person hasn't defined a born date nor a
deceased date.
"""
self.son.born_in = None
self.assertIsNone(self.son.is_alive())
def test_is_alive_not_alive(self):
"""
Tests the return value when a Person is dead, based on the object
dates.
"""
self.son.born_in = self.d
self.son.deceased_in = self.d
self.assertFalse(self.son.is_alive())
def test_is_alive_alive(self):
"""
Tests the return value when a Person is dead, based on the object
dates.
"""
self.son.born_in = self.d
self.assertTrue(self.son.is_alive())
def test_brothers(self):
"""
Tests the ``brothers()`` method to validate that returns other
:model:`family.Person` instances related by parents, but not the
current object.
"""
self.assertTrue(self not in self.son.brothers())
def test_parents(self):
"""
Tests the ``parents()`` method to validate that returns other
:model:`family.Person` instances related to the current one as parents.
"""
parents = self.son.parents()
self.assertEqual(2, len(parents))
self.assertTrue(self.son.father in parents)
self.assertTrue(self.son.mother in parents)
def test_descendence_invalid(self):
"""
Tests the ``descendence()`` method to validate that raises an exception
if current instance has not sex value defined.
"""
self.father.sex = None
self.assertRaises(ValueError, self.father.descendence)
def test_father_descendence(self):
"""
Tests the ``descendence()`` method to validate that returns other
:model:`family.Person` instances related to the current one as
father's descendence.
"""
d = self.father.descendence()
self.assertEqual(2, len(d))
self.assertTrue(self.son in d)
self.assertTrue(self.other_son in d)
def test_mother_descendence(self):
"""
Tests the ``descendence()`` method to validate that returns other
:model:`family.Person` instances related to the current one as
mother's descendence.
"""
d = self.mother.descendence()
self.assertEqual(2, len(d))
self.assertTrue(self.son in d)
self.assertTrue(self.other_son in d)