Пример #1
0
 def test_all_granparents(self):
     ## First find list of grandparents names
     allg_parents = set([Person.get_persons_name(i) for i in self.root_child.all_grandparents()])
     #print(allg_parents)
     #print(len(allg_parents))
     real_allgparents = set(['root_child_mom_mom_mom', 'root_child_dad_dad_mom', 'root_child_mom_dad_mom', 'root_child_dad_dad_dad', 'root_child_mom_dad_dad', 'root_child_mom_mom_dad', 'root_child_mom_dad', 'root_child_mom_mom', 'root_child_dad_mom', 'root_child_dad_mom_dad', 'root_child_dad_mom_mom', 'root_child_dad_dad'])
     self.assertEqual(allg_parents, real_allgparents)
     self.assertEqual(len(allg_parents), 12)
Пример #2
0
 def test_grandparents(self):
     ## First find list of granparents names
     ## Sort to maintain order (switched from sort to set after class discussion)
     ## Test grandparents 4 (added after class discussion)
     g_parents = set([Person.get_persons_name(i) for i in self.root_child.grandparents()])
     #print(g_parents)
     real_gparents = set(['root_child_dad_mom', 'root_child_mom_dad', 'root_child_dad_dad', 'root_child_mom_mom'])
     self.assertEqual(g_parents, real_gparents)
     self.assertEqual(len(g_parents), 4)
Пример #3
0
 def test_parents(self):
     root_child_parents = set([Person.get_persons_name(i) for i in self.root_child.parents()])
     self.assertEqual(len(root_child_parents), 2)
Пример #4
0
 def test_ancestors(self):
     selfs_ancestors = [Person.get_persons_name(i) for i in self.root_child.ancestors(1,4)]
     self.assertEqual(len(selfs_ancestors), 14)
Пример #5
0
 def test_all_ancestors_error(self):
     all_ancestors = set([Person.get_persons_name(i) for i in self.root_child.all_ancestors()])
     real_b_allancestors = set(['root_child_mom', 'root_child_mom_dad_dad', 'root_child_mom_dad_mom', 'root_child_dfud_dad', 'root_child_mom_mom_dad', 'root_child_dad_mom', 'root_child_mom_mom_mom', 'root_chiaodjflld_dad_dad_dad', 'root_child_dad_dad_mom', 'root_chightld_dad_mom_dad', 'root_child_dad_mom_mom', 'root_child_mom_dad', 'root_child_mom_mom', 'root_child_dad'])
     self.assertNotEqual(all_ancestors, real_b_allancestors)
Пример #6
0
 def test_all_ancestors(self):
     ## First get list of all ancestors
     all_ancestors = set([Person.get_persons_name(i) for i in self.root_child.all_ancestors()])
     ##print(all_ancestors)
     real_all_ancestors = set(['root_child_mom', 'root_child_mom_dad_dad', 'root_child_mom_dad_mom', 'root_child_dad_dad', 'root_child_mom_mom_dad', 'root_child_dad_mom', 'root_child_mom_mom_mom', 'root_child_dad_dad_dad', 'root_child_dad_dad_mom', 'root_child_dad_mom_dad', 'root_child_dad_mom_mom', 'root_child_mom_dad', 'root_child_mom_mom', 'root_child_dad'])
     self.assertEqual(all_ancestors, real_all_ancestors)
Пример #7
0
 def test_all_grandparents_error(self):
     allg_parents = set([Person.get_persons_name(i) for i in self.root_child.all_grandparents()])
     ## I used the set before I fixed the all_granndparents code
     real_b_allgparents = set(['root_child_dad_dad_mom', 'root_child_dad_mom_dad', 'root_child_dad_mom_mom', 'root_child_mom_daa_dad', 'root_child_sister_dad_mom', 'root_child_mom_mum_dad', 'root_child_mom_mom_mom', 'root_child_dad_dad_dad'])
     self.assertNotEqual(allg_parents, real_b_allgparents)
     self.assertNotEqual(len(allg_parents), len(real_b_allgparents))
Пример #8
0
 def test_grandparents_error(self):
     g_parents = set([Person.get_persons_name(i) for i in self.root_child.grandparents()])
     real_b_gparents = set(['root_child_dad_mum', 'root_child_mom_dad', 'root_child_da_dad', 'root_child_mom_mom'])
     self.assertNotEqual(g_parents, real_b_gparents)
Пример #9
0
 def test_get_persons_name(self):
     self.assertEqual(Person.get_persons_name(self.dad), 'dad')
     self.assertEqual(Person.get_persons_name(None), 'NA')
     self.assertEqual(Person.get_persons_name(self.child), self.child.name)