123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- import relationship
- import unittest
- relations_first_grade_female = [
- (('1.2.3.4.5', '1.2.3.4', 'w'), 'Mutter'),
- (('1.2.3.4.5', '1.2.3', 'w'), 'Großmutter'),
- (('1.2.3.4.5', '1.2', 'w'), 'Ur-Großmutter'),
- (('1.2.3.4.5', '1', 'w'), 'Ur-Ur-Großmutter'),
- (('1.2.3.4.5', '1.2.3.4.5.6', 'w'), 'Tochter'),
- (('1.2.3.4.5', '1.2.3.4.5.6.7', 'w'), 'Enkelin'),
- (('1.2.3.4.5', '1.2.3.4.5.6.7.8', 'w'), 'Ur-Enkelin'),
- (('1.2.3.4.5', '1.2.3.4.5.6.7.8.9', 'w'), 'Ur-Ur-Enkelin'),
- ]
- relations_second_grade_female = [
- (('1.2.3.4.5', '1.2.3.x', 'w'), 'Tante'),
- (('1.2.3.4.5', '1.2.x', 'w'), 'Großtante'),
- (('1.2.3.4.5', '1.x', 'w'), 'Ur-Großtante'),
- (('1.2.3.4.5', 'x', 'w'), 'Ur-Ur-Großtante'),
- (('1.2.3.4.5', '1.2.3.4.x', 'w'), 'Schwester'),
- (('1.2.3.4.5', '1.2.3.4.x.6', 'w'), 'Nichte'),
- (('1.2.3.4.5', '1.2.3.4.x.6.7', 'w'), 'Großnichte'),
- (('1.2.3.4.5', '1.2.3.4.x.6.7.8', 'w'), 'Ur-Großnichte'),
- (('1.2.3.4.5', '1.2.3.4.x.6.7.8.9', 'w'), 'Ur-Ur-Großnichte'),
- ]
- relations_higher_grade_female = [
- (('1.2.3.4.5', '1.2.3.x', 'w'), 'Tante'),
- (('1.2.3.4.5', '1.2.x.x', 'w'), 'Tante 2. Grades'),
- (('1.2.3.4.5', '1.x.x.x', 'w'), 'Tante 3. Grades'),
- (('1.2.3.4.5', 'x.x.x.x', 'w'), 'Tante 4. Grades'),
- (('1.2.3.4.5', '1.2.x', 'w'), 'Großtante'),
- (('1.2.3.4.5', '1.x.x', 'w'), 'Großtante 2. Grades'),
- (('1.2.3.4.5', 'x.x.x', 'w'), 'Großtante 3. Grades'),
- (('1.2.3.4.5', '1.x', 'w'), 'Ur-Großtante'),
- (('1.2.3.4.5', 'x.x', 'w'), 'Ur-Großtante 2. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x', 'w'), 'Nichte'),
- (('1.2.3.4.5', '1.2.3.x.x.x', 'w'), 'Nichte 2. Grades'),
- (('1.2.3.4.5', '1.2.x.x.x.x', 'w'), 'Nichte 3. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x.x', 'w'), 'Nichte 4. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x.x', 'w'), 'Großnichte'),
- (('1.2.3.4.5', '1.2.3.x.x.x.x', 'w'), 'Großnichte 2. Grades'),
- (('1.2.3.4.5', '1.2.x.x.x.x.x', 'w'), 'Großnichte 3. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x.x.x', 'w'), 'Großnichte 4. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x.x.x', 'w'), 'Ur-Großnichte'),
- (('1.2.3.4.5', '1.2.3.x.x.x.x.x', 'w'), 'Ur-Großnichte 2. Grades'),
- (('1.2.3.4.5', '1.2.x.x.x.x.x.x', 'w'), 'Ur-Großnichte 3. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x.x.x.x', 'w'), 'Ur-Großnichte 4. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x.x.x.x', 'w'), 'Ur-Ur-Großnichte'),
- (('1.2.3.4.5', '1.2.3.x.x.x.x.x.x', 'w'), 'Ur-Ur-Großnichte 2. Grades'),
- ]
- relations_special_grade_female = [
- (('1.2.3.4.5', '1.2.3.4.x', 'w'), 'Schwester'),
- (('1.2.3.4.5', '1.2.3.x.x', 'w'), 'Cousine'),
- (('1.2.3.4.5', '1.2.x.x.x', 'w'), 'Cousine 2. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x', 'w'), 'Cousine 3. Grades')
- ]
- relations_first_grade_male = [
- (('1.2.3.4.5', '1.2.3.4', 'm'), 'Vater'),
- (('1.2.3.4.5', '1.2.3', 'm'), 'Großvater'),
- (('1.2.3.4.5', '1.2', 'm'), 'Ur-Großvater'),
- (('1.2.3.4.5', '1', 'm'), 'Ur-Ur-Großvater'),
- (('1.2.3.4.5', '1.2.3.4.5.6', 'm'), 'Sohn'),
- (('1.2.3.4.5', '1.2.3.4.5.6.7', 'm'), 'Enkel'),
- (('1.2.3.4.5', '1.2.3.4.5.6.7.8', 'm'), 'Ur-Enkel'),
- (('1.2.3.4.5', '1.2.3.4.5.6.7.8.9', 'm'), 'Ur-Ur-Enkel'),
- ]
- relations_second_grade_male = [
- (('1.2.3.4.5', '1.2.3.x', 'm'), 'Onkel'),
- (('1.2.3.4.5', '1.2.x', 'm'), 'Großonkel'),
- (('1.2.3.4.5', '1.x', 'm'), 'Ur-Großonkel'),
- (('1.2.3.4.5', 'x', 'm'), 'Ur-Ur-Großonkel'),
- (('1.2.3.4.5', '1.2.3.4.x', 'm'), 'Bruder'),
- (('1.2.3.4.5', '1.2.3.4.x.6', 'm'), 'Neffe'),
- (('1.2.3.4.5', '1.2.3.4.x.6.7', 'm'), 'Großneffe'),
- (('1.2.3.4.5', '1.2.3.4.x.6.7.8', 'm'), 'Ur-Großneffe'),
- (('1.2.3.4.5', '1.2.3.4.x.6.7.8.9', 'm'), 'Ur-Ur-Großneffe'),
- ]
- relations_higher_grade_male = [
- (('1.2.3.4.5', '1.2.3.x', 'm'), 'Onkel'),
- (('1.2.3.4.5', '1.2.x.x', 'm'), 'Onkel 2. Grades'),
- (('1.2.3.4.5', '1.x.x.x', 'm'), 'Onkel 3. Grades'),
- (('1.2.3.4.5', 'x.x.x.x', 'm'), 'Onkel 4. Grades'),
- (('1.2.3.4.5', '1.2.x', 'm'), 'Großonkel'),
- (('1.2.3.4.5', '1.x.x', 'm'), 'Großonkel 2. Grades'),
- (('1.2.3.4.5', 'x.x.x', 'm'), 'Großonkel 3. Grades'),
- (('1.2.3.4.5', '1.x', 'm'), 'Ur-Großonkel'),
- (('1.2.3.4.5', 'x.x', 'm'), 'Ur-Großonkel 2. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x', 'm'), 'Neffe'),
- (('1.2.3.4.5', '1.2.3.x.x.x', 'm'), 'Neffe 2. Grades'),
- (('1.2.3.4.5', '1.2.x.x.x.x', 'm'), 'Neffe 3. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x.x', 'm'), 'Neffe 4. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x.x', 'm'), 'Großneffe'),
- (('1.2.3.4.5', '1.2.3.x.x.x.x', 'm'), 'Großneffe 2. Grades'),
- (('1.2.3.4.5', '1.2.x.x.x.x.x', 'm'), 'Großneffe 3. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x.x.x', 'm'), 'Großneffe 4. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x.x.x', 'm'), 'Ur-Großneffe'),
- (('1.2.3.4.5', '1.2.3.x.x.x.x.x', 'm'), 'Ur-Großneffe 2. Grades'),
- (('1.2.3.4.5', '1.2.x.x.x.x.x.x', 'm'), 'Ur-Großneffe 3. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x.x.x.x', 'm'), 'Ur-Großneffe 4. Grades'),
- (('1.2.3.4.5', '1.2.3.4.x.x.x.x.x', 'm'), 'Ur-Ur-Großneffe'),
- (('1.2.3.4.5', '1.2.3.x.x.x.x.x.x', 'm'), 'Ur-Ur-Großneffe 2. Grades'),
- ]
- relations_special_grade_male = [
- (('1.2.3.4.5', '1.2.3.4.x', 'm'), 'Bruder'),
- (('1.2.3.4.5', '1.2.3.x.x', 'm'), 'Cousin'),
- (('1.2.3.4.5', '1.2.x.x.x', 'm'), 'Cousin 2. Grades'),
- (('1.2.3.4.5', '1.x.x.x.x', 'm'), 'Cousin 3. Grades')
- ]
- relations_higher_grade_distance = [
- (('1.2.3.4.5', '1.2.3.4.5.6', 'w'), 'Tochter', 1),
- (('1.2.3.4.5', '1.2.3.4.5.6.7', 'w'), 'Enkelin', 2),
- (('1.2.3.4.5', '1', 'w'), 'Ur-Ur-Großmutter', 4),
- (('1.2.3.4.5', '1.2.3.x', 'w'), 'Tante', 3),
- (('1.2.3.4.5', '1.2.x.x', 'w'), 'Tante 2. Grades', 5),
- (('1.2.3.4.5', '1.x.x.x', 'w'), 'Tante 3. Grades', 7),
- (('1.2.3.4.5', 'x.x.x.x', 'w'), 'Tante 4. Grades', 9),
- (('1.2.3.4.5', '1.2.x', 'w'), 'Großtante', 4),
- (('1.2.3.4.5', '1.x.x', 'w'), 'Großtante 2. Grades', 6),
- (('1.2.3.4.5', 'x.x.x', 'w'), 'Großtante 3. Grades', 8),
- (('1.2.3.4.5', '1.x', 'w'), 'Ur-Großtante', 5),
- (('1.2.3.4.5', 'x.x', 'w'), 'Ur-Großtante 2. Grades', 7),
- (('1.2.3.4.5', '1.2.3.4.x.x', 'w'), 'Nichte', 3),
- (('1.2.3.4.5', '1.2.3.x.x.x', 'w'), 'Nichte 2. Grades', 5),
- (('1.2.3.4.5', '1.2.x.x.x.x', 'w'), 'Nichte 3. Grades', 7),
- (('1.2.3.4.5', '1.x.x.x.x.x', 'w'), 'Nichte 4. Grades', 9),
- (('1.2.3.4.5', '1.2.3.4.x.x.x', 'w'), 'Großnichte', 4),
- (('1.2.3.4.5', '1.2.3.x.x.x.x', 'w'), 'Großnichte 2. Grades', 6),
- (('1.2.3.4.5', '1.2.x.x.x.x.x', 'w'), 'Großnichte 3. Grades', 8),
- (('1.2.3.4.5', '1.x.x.x.x.x.x', 'w'), 'Großnichte 4. Grades', 10),
- (('1.2.3.4.5', '1.2.3.4.x.x.x.x', 'w'), 'Ur-Großnichte', 5),
- (('1.2.3.4.5', '1.2.3.x.x.x.x.x', 'w'), 'Ur-Großnichte 2. Grades', 7),
- (('1.2.3.4.5', '1.2.x.x.x.x.x.x', 'w'), 'Ur-Großnichte 3. Grades', 9),
- (('1.2.3.4.5', '1.x.x.x.x.x.x.x', 'w'), 'Ur-Großnichte 4. Grades', 11),
- (('1.2.3.4.5', '1.2.3.4.x.x.x.x.x', 'w'), 'Ur-Ur-Großnichte', 6),
- (('1.2.3.4.5', '1.2.3.x.x.x.x.x.x', 'w'), 'Ur-Ur-Großnichte 2. Grades', 8),
- ]
- burghard = [
- ('Harald', '1.4.6.3.4', 'm'),
- ('Alice', '1.4.6.3.4.1', 'w'),
- ('Janina', '1.4.6.3.4.2', 'w'),
- ('Theresa', '1.4.6.3.4.2.1', 'w'),
- ('Valentin', '1.4.6.3.4.2.2', 'm'),
- ('Freya', '1.4.6.3.4.3', 'w')
- ]
- burghard_freya = [
- ('Freya', '1.4.6.3.4.3', 'w', 'Tochter', 'Harald', '1.4.6.3.4', 'm', 'Vater', 1)
- ]
- burghard_all = [
- ('Harald', '1.4.6.3.4', 'm', 'ich', 'Harald', '1.4.6.3.4', 'm', 'ich', 0)
- ]
- class test_relatives(unittest.TestCase):
- def test_first_grade_female(self):
- self.relations(relations_first_grade_female)
- def test_second_grade_female(self):
- self.relations(relations_second_grade_female)
- def test_higher_grade_female(self):
- self.relations(relations_higher_grade_female)
- def test_special_grade_female(self):
- self.relations(relations_special_grade_female)
- def test_first_grade_male(self):
- self.relations(relations_first_grade_male)
- def test_second_grade_male(self):
- self.relations(relations_second_grade_male)
- def test_higher_grade_male(self):
- self.relations(relations_higher_grade_male)
- def test_special_grade_male(self):
- self.relations(relations_special_grade_male)
- def relations(self, relations_list):
- for rel, title in relations_list:
- result = relationship.relationship_name(*rel)
- self.assertEqual(result, title)
- def test_distance(self):
- for rel, title, distance in relations_higher_grade_distance:
- result = relationship.relationship_distance(rel[0], rel[1])
- self.assertEqual(result, distance, title)
- def test_relations_list(self):
- result = relationship.relationship_list(burghard, 5)
- self.assertEqual(result[0], burghard_freya[0])
- def test_relations_list_all(self):
- result = relationship.relationship_list_all(burghard)
- self.assertEqual(result[0], burghard_all[0])
- if __name__ == '__main__':
- unittest.main()
|