|
11 | 11 | from ietf.utils.test_utils import login_testing_unauthorized |
12 | 12 | from ietf.utils.pipe import pipe |
13 | 13 |
|
| 14 | +from ietf.person.models import Email, Person |
| 15 | + |
14 | 16 | from ietf.nomcom.test_data import nomcom_test_data, COMMUNITY_USER, CHAIR_USER, \ |
15 | 17 | MEMBER_USER, SECRETARIAT_USER, EMAIL_DOMAIN |
16 | 18 | from ietf.nomcom.models import NomineePosition, Position, Nominee, \ |
17 | | - NomineePositionState, Feedback, FeedbackType |
| 19 | + NomineePositionState, Feedback, FeedbackType, \ |
| 20 | + Nomination |
18 | 21 | from ietf.nomcom.forms import EditChairForm, EditMembersForm |
| 22 | +from ietf.nomcom.utils import get_nomcom_by_year |
19 | 23 |
|
20 | 24 |
|
21 | 25 | class NomcomViewsTest(TestCase): |
@@ -161,9 +165,50 @@ def test_comments_view(self): |
161 | 165 |
|
162 | 166 | def test_nominate_view(self): |
163 | 167 | """Verify nominate view""" |
164 | | - # TODO: complete to do a nomination |
165 | 168 | login_testing_unauthorized(self, COMMUNITY_USER, self.nominate_url) |
166 | | - self.check_url_status(self.nominate_url, 200) |
| 169 | + response = self.client.get(self.nominate_url) |
| 170 | + self.assertEqual(response.status_code, 200) |
| 171 | + nomcom = get_nomcom_by_year(self.year) |
| 172 | + has_publickey = nomcom.public_key and True or False |
| 173 | + self.assertEqual(response.context['has_publickey'], has_publickey) |
| 174 | + |
| 175 | + if not has_publickey: |
| 176 | + return |
| 177 | + |
| 178 | + position = Position.objects.get(name='IAOC') |
| 179 | + candidate_email = 'nominee@example.com', |
| 180 | + candidate_name = 'nominee' |
| 181 | + comments = 'test nominate view' |
| 182 | + candidate_phone = '123456' |
| 183 | + |
| 184 | + test_data = {'candidate_name': candidate_name, |
| 185 | + 'candidate_email': candidate_email, |
| 186 | + 'candidate_phone': candidate_phone, |
| 187 | + 'position': position.id, |
| 188 | + 'comments': comments} |
| 189 | + |
| 190 | + response = self.client.post(self.nominate_url, test_data) |
| 191 | + self.assertEqual(response.status_code, 200) |
| 192 | + |
| 193 | + # check objects |
| 194 | + email = Email.objects.get(address=candidate_email) |
| 195 | + Person.objects.get(name=candidate_name, address=candidate_email) |
| 196 | + nominee = Nominee.objects.get(email=email) |
| 197 | + NomineePosition.objects.get(position=position, nominee=nominee) |
| 198 | + feedback = Feedback.objects.get(position=position, |
| 199 | + nominee=nominee, |
| 200 | + type=FeedbackType.objects.get(slug='nomina'), |
| 201 | + author__person__name=COMMUNITY_USER) |
| 202 | + # to check feedback comments are saved like enrypted data |
| 203 | + self.assertNotEqual(feedback.comments, comments) |
| 204 | + |
| 205 | + Nomination.objects.get(position=position, |
| 206 | + candidate_name=candidate_name, |
| 207 | + candidate_mail=candidate_email, |
| 208 | + candidate_phone=candidate_phone, |
| 209 | + nominee=nominee, |
| 210 | + comments=feedback, |
| 211 | + nominator_email="%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) |
167 | 212 | self.client.logout() |
168 | 213 |
|
169 | 214 |
|
|
0 commit comments