1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
# test_person.py |
4
|
|
|
"""Tests for `person` package.""" |
5
|
|
|
import pytest |
6
|
|
|
from context import helpers # noqa |
7
|
|
|
from context import politician_role # noqa |
8
|
|
|
|
9
|
|
|
# pylint: disable=redefined-outer-name |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
def test_person_Politician(politician_fixture): |
13
|
|
|
# pylint: disable=W0612, W0613 |
14
|
|
|
|
15
|
|
|
pol_1 = politician_role.Politician( |
16
|
|
|
"CDU", |
17
|
|
|
"Regina", |
18
|
|
|
"Dinther", |
19
|
|
|
peer_title="van", |
20
|
|
|
electoral_ward="Rhein-Sieg-Kreis IV", |
21
|
|
|
) |
22
|
|
|
|
23
|
|
|
assert pol_1.first_name == "Regina" # nosec |
24
|
|
|
assert pol_1.last_name == "Dinther" # nosec |
25
|
|
|
assert pol_1.gender == "female" # nosec |
26
|
|
|
assert pol_1.peer_preposition == "van" # nosec |
27
|
|
|
assert pol_1.party_name == "CDU" # nosec |
28
|
|
|
assert pol_1.ward_no == 28 # nosec |
29
|
|
|
assert pol_1.voter_count == 110389 # nosec |
30
|
|
|
|
31
|
|
|
pol_1.party_name = "fraktionslos" |
32
|
|
|
assert pol_1.party_name == "fraktionslos" # nosec |
33
|
|
|
assert pol_1.parties == [ # nosec |
34
|
|
|
helpers.Party( |
35
|
|
|
party_name="CDU", party_entry="unknown", party_exit="unknown" |
36
|
|
|
) # noqa # nosec |
37
|
|
|
] # noqa # nosec |
38
|
|
|
|
39
|
|
|
pol_2 = politician_role.Politician( |
40
|
|
|
"CDU", |
41
|
|
|
"Regina", |
42
|
|
|
"Dinther", |
43
|
|
|
electoral_ward="Landesliste", |
44
|
|
|
) # noqa |
45
|
|
|
|
46
|
|
|
assert pol_2.electoral_ward == "ew" # nosec |
47
|
|
|
|
48
|
|
|
pol_3 = politician_role.Politician( |
49
|
|
|
"Piraten", |
50
|
|
|
"Heiner", |
51
|
|
|
"Wiekeiner", |
52
|
|
|
electoral_ward="Kreis Aachen I", |
53
|
|
|
) # noqa |
54
|
|
|
|
55
|
|
|
assert pol_3.voter_count == 116389 # nosec |
56
|
|
|
|
57
|
|
|
with pytest.raises(helpers.NotGermanParty): |
58
|
|
|
pol_4 = politician_role.Politician( |
59
|
|
|
"Thomas", "Gschwindner", "not_a_German_party" |
60
|
|
|
) # noqa |
61
|
|
|
|
62
|
|
|
pol_4 = politician_role.Politician("FDP", "Thomas", "Gschwindner") |
63
|
|
|
pol_4.add_Party("FDP") |
64
|
|
|
|
65
|
|
|
assert pol_4.party_name == "FDP" # nosec |
66
|
|
|
assert pol_4.parties == [ # nosec |
67
|
|
|
helpers.Party( |
68
|
|
|
party_name="FDP", party_entry="unknown", party_exit="unknown" |
69
|
|
|
) # noqa # nosec |
70
|
|
|
] # noqa # nosec |
71
|
|
|
|
72
|
|
|
pol_4.add_Party("not_a_German_party") |
73
|
|
|
|
74
|
|
|
assert pol_4.party_name == "FDP" # nosec |
75
|
|
|
assert pol_4.parties == [ # nosec |
76
|
|
|
helpers.Party( |
77
|
|
|
party_name="FDP", party_entry="unknown", party_exit="unknown" |
78
|
|
|
) # noqa # nosec |
79
|
|
|
] # noqa # nosec |
80
|
|
|
|
81
|
|
|
pol_4.add_Party("AfD") |
82
|
|
|
|
83
|
|
|
assert pol_4.parties == [ # nosec |
84
|
|
|
helpers.Party( |
85
|
|
|
party_name="FDP", party_entry="unknown", party_exit="unknown" |
86
|
|
|
), # noqa # nosec |
87
|
|
|
helpers.Party( |
88
|
|
|
party_name="AfD", party_entry="unknown", party_exit="unknown" |
89
|
|
|
), # noqa # nosec |
90
|
|
|
] |
91
|
|
|
|
92
|
|
|
pol_4.add_Party("AfD", party_entry="2019") |
93
|
|
|
|
94
|
|
|
assert pol_4.party_entry == "2019" # nosec |
95
|
|
|
assert pol_4.parties == [ # nosec |
96
|
|
|
helpers.Party( |
97
|
|
|
party_name="FDP", party_entry="unknown", party_exit="unknown" |
98
|
|
|
), # noqa # nosec |
99
|
|
|
helpers.Party( |
100
|
|
|
party_name="AfD", party_entry="2019", party_exit="unknown" |
101
|
|
|
), # noqa # nosec |
102
|
|
|
] |
103
|
|
|
|
104
|
|
|
pol_4.add_Party("AfD", party_entry="2019", party_exit="2020") |
105
|
|
|
|
106
|
|
|
assert pol_4.party_exit == "2020" # nosec |
107
|
|
|
assert pol_4.parties == [ # nosec |
108
|
|
|
helpers.Party( |
109
|
|
|
party_name="FDP", party_entry="unknown", party_exit="unknown" |
110
|
|
|
), # noqa # nosec |
111
|
|
|
helpers.Party(party_name="AfD", party_entry="2019", party_exit="2020"), |
112
|
|
|
] |
113
|
|
|
|
114
|
|
|
pol_5 = politician_role.Politician( |
115
|
|
|
"Linke", "Heiner", "Wiekeiner", electoral_ward="Köln I" |
116
|
|
|
) # noqa |
117
|
|
|
|
118
|
|
|
assert pol_5.ward_no == 13 # nosec |
119
|
|
|
assert pol_5.voter_count == 121721 # nosec |
120
|
|
|
|
121
|
|
|
pol_6 = politician_role.Politician("Grüne", "Heiner", "Wiekeiner") |
122
|
|
|
|
123
|
|
|
assert pol_6.electoral_ward == "ew" # nosec |
124
|
|
|
assert pol_6.ward_no is None # nosec |
125
|
|
|
assert pol_6.voter_count is None # nosec |
126
|
|
|
|
127
|
|
|
pol_6.change_ward("Essen III") |
128
|
|
|
|
129
|
|
|
assert pol_6.electoral_ward == "Essen III" # nosec |
130
|
|
|
assert pol_6.ward_no == 67 # nosec |
131
|
|
|
assert pol_6.voter_count == 104181 # nosec |
132
|
|
|
|