test_relationship.py 8.5 KB

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