test_relationship.py 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import unittest
  2. from sandbox import relationship
  3. relations_first_grade_female = [
  4. (("1.2.3.4.5", "1.2.3.4", "w"), "Mutter"),
  5. (("1.2.3.4.5", "1.2.3", "w"), "Großmutter"),
  6. (("1.2.3.4.5", "1.2", "w"), "Ur-Großmutter"),
  7. (("1.2.3.4.5", "1", "w"), "Ur-Ur-Großmutter"),
  8. (("1.2.3.4.5", "1.2.3.4.5.6", "w"), "Tochter"),
  9. (("1.2.3.4.5", "1.2.3.4.5.6.7", "w"), "Enkelin"),
  10. (("1.2.3.4.5", "1.2.3.4.5.6.7.8", "w"), "Ur-Enkelin"),
  11. (("1.2.3.4.5", "1.2.3.4.5.6.7.8.9", "w"), "Ur-Ur-Enkelin"),
  12. ]
  13. relations_second_grade_female = [
  14. (("1.2.3.4.5", "1.2.3.x", "w"), "Tante"),
  15. (("1.2.3.4.5", "1.2.x", "w"), "Großtante"),
  16. (("1.2.3.4.5", "1.x", "w"), "Ur-Großtante"),
  17. (("1.2.3.4.5", "x", "w"), "Ur-Ur-Großtante"),
  18. (("1.2.3.4.5", "1.2.3.4.x", "w"), "Schwester"),
  19. (("1.2.3.4.5", "1.2.3.4.x.6", "w"), "Nichte"),
  20. (("1.2.3.4.5", "1.2.3.4.x.6.7", "w"), "Großnichte"),
  21. (("1.2.3.4.5", "1.2.3.4.x.6.7.8", "w"), "Ur-Großnichte"),
  22. (("1.2.3.4.5", "1.2.3.4.x.6.7.8.9", "w"), "Ur-Ur-Großnichte"),
  23. ]
  24. relations_higher_grade_female = [
  25. (("1.2.3.4.5", "1.2.3.x", "w"), "Tante"),
  26. (("1.2.3.4.5", "1.2.x.x", "w"), "Tante 2. Grades"),
  27. (("1.2.3.4.5", "1.x.x.x", "w"), "Tante 3. Grades"),
  28. (("1.2.3.4.5", "x.x.x.x", "w"), "Tante 4. Grades"),
  29. (("1.2.3.4.5", "1.2.x", "w"), "Großtante"),
  30. (("1.2.3.4.5", "1.x.x", "w"), "Großtante 2. Grades"),
  31. (("1.2.3.4.5", "x.x.x", "w"), "Großtante 3. Grades"),
  32. (("1.2.3.4.5", "1.x", "w"), "Ur-Großtante"),
  33. (("1.2.3.4.5", "x.x", "w"), "Ur-Großtante 2. Grades"),
  34. (("1.2.3.4.5", "1.2.3.4.x.x", "w"), "Nichte"),
  35. (("1.2.3.4.5", "1.2.3.x.x.x", "w"), "Nichte 2. Grades"),
  36. (("1.2.3.4.5", "1.2.x.x.x.x", "w"), "Nichte 3. Grades"),
  37. (("1.2.3.4.5", "1.x.x.x.x.x", "w"), "Nichte 4. Grades"),
  38. (("1.2.3.4.5", "1.2.3.4.x.x.x", "w"), "Großnichte"),
  39. (("1.2.3.4.5", "1.2.3.x.x.x.x", "w"), "Großnichte 2. Grades"),
  40. (("1.2.3.4.5", "1.2.x.x.x.x.x", "w"), "Großnichte 3. Grades"),
  41. (("1.2.3.4.5", "1.x.x.x.x.x.x", "w"), "Großnichte 4. Grades"),
  42. (("1.2.3.4.5", "1.2.3.4.x.x.x.x", "w"), "Ur-Großnichte"),
  43. (("1.2.3.4.5", "1.2.3.x.x.x.x.x", "w"), "Ur-Großnichte 2. Grades"),
  44. (("1.2.3.4.5", "1.2.x.x.x.x.x.x", "w"), "Ur-Großnichte 3. Grades"),
  45. (("1.2.3.4.5", "1.x.x.x.x.x.x.x", "w"), "Ur-Großnichte 4. Grades"),
  46. (("1.2.3.4.5", "1.2.3.4.x.x.x.x.x", "w"), "Ur-Ur-Großnichte"),
  47. (("1.2.3.4.5", "1.2.3.x.x.x.x.x.x", "w"), "Ur-Ur-Großnichte 2. Grades"),
  48. ]
  49. relations_special_grade_female = [
  50. (("1.2.3.4.5", "1.2.3.4.x", "w"), "Schwester"),
  51. (("1.2.3.4.5", "1.2.3.x.x", "w"), "Cousine"),
  52. (("1.2.3.4.5", "1.2.x.x.x", "w"), "Cousine 2. Grades"),
  53. (("1.2.3.4.5", "1.x.x.x.x", "w"), "Cousine 3. Grades"),
  54. ]
  55. relations_first_grade_male = [
  56. (("1.2.3.4.5", "1.2.3.4", "m"), "Vater"),
  57. (("1.2.3.4.5", "1.2.3", "m"), "Großvater"),
  58. (("1.2.3.4.5", "1.2", "m"), "Ur-Großvater"),
  59. (("1.2.3.4.5", "1", "m"), "Ur-Ur-Großvater"),
  60. (("1.2.3.4.5", "1.2.3.4.5.6", "m"), "Sohn"),
  61. (("1.2.3.4.5", "1.2.3.4.5.6.7", "m"), "Enkel"),
  62. (("1.2.3.4.5", "1.2.3.4.5.6.7.8", "m"), "Ur-Enkel"),
  63. (("1.2.3.4.5", "1.2.3.4.5.6.7.8.9", "m"), "Ur-Ur-Enkel"),
  64. ]
  65. relations_second_grade_male = [
  66. (("1.2.3.4.5", "1.2.3.x", "m"), "Onkel"),
  67. (("1.2.3.4.5", "1.2.x", "m"), "Großonkel"),
  68. (("1.2.3.4.5", "1.x", "m"), "Ur-Großonkel"),
  69. (("1.2.3.4.5", "x", "m"), "Ur-Ur-Großonkel"),
  70. (("1.2.3.4.5", "1.2.3.4.x", "m"), "Bruder"),
  71. (("1.2.3.4.5", "1.2.3.4.x.6", "m"), "Neffe"),
  72. (("1.2.3.4.5", "1.2.3.4.x.6.7", "m"), "Großneffe"),
  73. (("1.2.3.4.5", "1.2.3.4.x.6.7.8", "m"), "Ur-Großneffe"),
  74. (("1.2.3.4.5", "1.2.3.4.x.6.7.8.9", "m"), "Ur-Ur-Großneffe"),
  75. ]
  76. relations_higher_grade_male = [
  77. (("1.2.3.4.5", "1.2.3.x", "m"), "Onkel"),
  78. (("1.2.3.4.5", "1.2.x.x", "m"), "Onkel 2. Grades"),
  79. (("1.2.3.4.5", "1.x.x.x", "m"), "Onkel 3. Grades"),
  80. (("1.2.3.4.5", "x.x.x.x", "m"), "Onkel 4. Grades"),
  81. (("1.2.3.4.5", "1.2.x", "m"), "Großonkel"),
  82. (("1.2.3.4.5", "1.x.x", "m"), "Großonkel 2. Grades"),
  83. (("1.2.3.4.5", "x.x.x", "m"), "Großonkel 3. Grades"),
  84. (("1.2.3.4.5", "1.x", "m"), "Ur-Großonkel"),
  85. (("1.2.3.4.5", "x.x", "m"), "Ur-Großonkel 2. Grades"),
  86. (("1.2.3.4.5", "1.2.3.4.x.x", "m"), "Neffe"),
  87. (("1.2.3.4.5", "1.2.3.x.x.x", "m"), "Neffe 2. Grades"),
  88. (("1.2.3.4.5", "1.2.x.x.x.x", "m"), "Neffe 3. Grades"),
  89. (("1.2.3.4.5", "1.x.x.x.x.x", "m"), "Neffe 4. Grades"),
  90. (("1.2.3.4.5", "1.2.3.4.x.x.x", "m"), "Großneffe"),
  91. (("1.2.3.4.5", "1.2.3.x.x.x.x", "m"), "Großneffe 2. Grades"),
  92. (("1.2.3.4.5", "1.2.x.x.x.x.x", "m"), "Großneffe 3. Grades"),
  93. (("1.2.3.4.5", "1.x.x.x.x.x.x", "m"), "Großneffe 4. Grades"),
  94. (("1.2.3.4.5", "1.2.3.4.x.x.x.x", "m"), "Ur-Großneffe"),
  95. (("1.2.3.4.5", "1.2.3.x.x.x.x.x", "m"), "Ur-Großneffe 2. Grades"),
  96. (("1.2.3.4.5", "1.2.x.x.x.x.x.x", "m"), "Ur-Großneffe 3. Grades"),
  97. (("1.2.3.4.5", "1.x.x.x.x.x.x.x", "m"), "Ur-Großneffe 4. Grades"),
  98. (("1.2.3.4.5", "1.2.3.4.x.x.x.x.x", "m"), "Ur-Ur-Großneffe"),
  99. (("1.2.3.4.5", "1.2.3.x.x.x.x.x.x", "m"), "Ur-Ur-Großneffe 2. Grades"),
  100. ]
  101. relations_special_grade_male = [
  102. (("1.2.3.4.5", "1.2.3.4.x", "m"), "Bruder"),
  103. (("1.2.3.4.5", "1.2.3.x.x", "m"), "Cousin"),
  104. (("1.2.3.4.5", "1.2.x.x.x", "m"), "Cousin 2. Grades"),
  105. (("1.2.3.4.5", "1.x.x.x.x", "m"), "Cousin 3. Grades"),
  106. ]
  107. relations_higher_grade_distance = [
  108. (("1.2.3.4.5", "1.2.3.4.5.6", "w"), "Tochter", 1),
  109. (("1.2.3.4.5", "1.2.3.4.5.6.7", "w"), "Enkelin", 2),
  110. (("1.2.3.4.5", "1", "w"), "Ur-Ur-Großmutter", 4),
  111. (("1.2.3.4.5", "1.2.3.x", "w"), "Tante", 3),
  112. (("1.2.3.4.5", "1.2.x.x", "w"), "Tante 2. Grades", 5),
  113. (("1.2.3.4.5", "1.x.x.x", "w"), "Tante 3. Grades", 7),
  114. (("1.2.3.4.5", "x.x.x.x", "w"), "Tante 4. Grades", 9),
  115. (("1.2.3.4.5", "1.2.x", "w"), "Großtante", 4),
  116. (("1.2.3.4.5", "1.x.x", "w"), "Großtante 2. Grades", 6),
  117. (("1.2.3.4.5", "x.x.x", "w"), "Großtante 3. Grades", 8),
  118. (("1.2.3.4.5", "1.x", "w"), "Ur-Großtante", 5),
  119. (("1.2.3.4.5", "x.x", "w"), "Ur-Großtante 2. Grades", 7),
  120. (("1.2.3.4.5", "1.2.3.4.x.x", "w"), "Nichte", 3),
  121. (("1.2.3.4.5", "1.2.3.x.x.x", "w"), "Nichte 2. Grades", 5),
  122. (("1.2.3.4.5", "1.2.x.x.x.x", "w"), "Nichte 3. Grades", 7),
  123. (("1.2.3.4.5", "1.x.x.x.x.x", "w"), "Nichte 4. Grades", 9),
  124. (("1.2.3.4.5", "1.2.3.4.x.x.x", "w"), "Großnichte", 4),
  125. (("1.2.3.4.5", "1.2.3.x.x.x.x", "w"), "Großnichte 2. Grades", 6),
  126. (("1.2.3.4.5", "1.2.x.x.x.x.x", "w"), "Großnichte 3. Grades", 8),
  127. (("1.2.3.4.5", "1.x.x.x.x.x.x", "w"), "Großnichte 4. Grades", 10),
  128. (("1.2.3.4.5", "1.2.3.4.x.x.x.x", "w"), "Ur-Großnichte", 5),
  129. (("1.2.3.4.5", "1.2.3.x.x.x.x.x", "w"), "Ur-Großnichte 2. Grades", 7),
  130. (("1.2.3.4.5", "1.2.x.x.x.x.x.x", "w"), "Ur-Großnichte 3. Grades", 9),
  131. (("1.2.3.4.5", "1.x.x.x.x.x.x.x", "w"), "Ur-Großnichte 4. Grades", 11),
  132. (("1.2.3.4.5", "1.2.3.4.x.x.x.x.x", "w"), "Ur-Ur-Großnichte", 6),
  133. (("1.2.3.4.5", "1.2.3.x.x.x.x.x.x", "w"), "Ur-Ur-Großnichte 2. Grades", 8),
  134. ]
  135. burghard = [
  136. ("Harald", "1.4.6.3.4", "m"),
  137. ("Alice", "1.4.6.3.4.1", "w"),
  138. ("Janina", "1.4.6.3.4.2", "w"),
  139. ("Theresa", "1.4.6.3.4.2.1", "w"),
  140. ("Valentin", "1.4.6.3.4.2.2", "m"),
  141. ("Freya", "1.4.6.3.4.3", "w"),
  142. ]
  143. burghard_freya = [("Freya", "1.4.6.3.4.3", "w", "Tochter", "Harald", "1.4.6.3.4", "m", "Vater", 1)]
  144. burghard_all = [("Harald", "1.4.6.3.4", "m", "ich", "Harald", "1.4.6.3.4", "m", "ich", 0)]
  145. class test_relatives(unittest.TestCase):
  146. def test_first_grade_female(self):
  147. self.relations(relations_first_grade_female)
  148. def test_second_grade_female(self):
  149. self.relations(relations_second_grade_female)
  150. def test_higher_grade_female(self):
  151. self.relations(relations_higher_grade_female)
  152. def test_special_grade_female(self):
  153. self.relations(relations_special_grade_female)
  154. def test_first_grade_male(self):
  155. self.relations(relations_first_grade_male)
  156. def test_second_grade_male(self):
  157. self.relations(relations_second_grade_male)
  158. def test_higher_grade_male(self):
  159. self.relations(relations_higher_grade_male)
  160. def test_special_grade_male(self):
  161. self.relations(relations_special_grade_male)
  162. def relations(self, relations_list):
  163. for rel, title in relations_list:
  164. result = relationship.relationship_name(*rel)
  165. self.assertEqual(result, title)
  166. def test_distance(self):
  167. for rel, title, distance in relations_higher_grade_distance:
  168. result = relationship.relationship_distance(rel[0], rel[1])
  169. self.assertEqual(result, distance, title)
  170. def test_relations_list(self):
  171. result = relationship.relationship_list(burghard, 5)
  172. self.assertEqual(result[0], burghard_freya[0])
  173. def test_relations_list_all(self):
  174. result = relationship.relationship_list_all(burghard)
  175. self.assertEqual(result[0], burghard_all[0])
  176. if __name__ == "__main__":
  177. unittest.main()