|
27 | 27 | NomineePositionStateName, Feedback, FeedbackTypeName, \ |
28 | 28 | Nomination |
29 | 29 | from ietf.nomcom.forms import EditMembersForm, EditMembersFormPreview |
30 | | -from ietf.nomcom.utils import get_nomcom_by_year, get_or_create_nominee |
| 30 | +from ietf.nomcom.utils import get_nomcom_by_year, get_or_create_nominee, get_hash_nominee_position |
31 | 31 | from ietf.nomcom.management.commands.send_reminders import Command, is_time_to_send |
32 | 32 |
|
33 | | -from ietf.nomcom.factories import NomComFactory, nomcom_kwargs_for_year |
| 33 | +from ietf.nomcom.factories import NomComFactory, nomcom_kwargs_for_year, provide_private_key_to_test_client |
34 | 34 | from ietf.person.factories import PersonFactory |
| 35 | +from ietf.dbtemplate.factories import DBTemplateFactory |
35 | 36 |
|
36 | 37 | client_test_cert_files = None |
37 | 38 |
|
@@ -928,11 +929,13 @@ class InactiveNomcomTests(TestCase): |
928 | 929 | def setUp(self): |
929 | 930 | self.nc = NomComFactory.create(**nomcom_kwargs_for_year(group__state_id='conclude')) |
930 | 931 | self.plain_person = PersonFactory.create() |
| 932 | + self.chair = self.nc.group.role_set.filter(name='chair').first().person |
| 933 | + self.member = self.nc.group.role_set.filter(name='member').first().person |
931 | 934 |
|
932 | 935 | def test_feedback_closed(self): |
933 | 936 | for view in ['nomcom_public_feedback', 'nomcom_private_feedback']: |
934 | 937 | url = reverse(view, kwargs={'year': self.nc.year()}) |
935 | | - who = self.plain_person if 'public' in view else self.nc.group.role_set.filter(name='member').first().person |
| 938 | + who = self.plain_person if 'public' in view else self.member |
936 | 939 | login_testing_unauthorized(self, who.user.username, url) |
937 | 940 | response = self.client.get(url) |
938 | 941 | self.assertEqual(response.status_code, 200) |
@@ -963,11 +966,151 @@ def test_feedback_closed(self): |
963 | 966 | def test_nominations_closed(self): |
964 | 967 | for view in ['nomcom_public_nominate', 'nomcom_private_nominate']: |
965 | 968 | url = reverse(view, kwargs={'year': self.nc.year() }) |
966 | | - who = self.plain_person if 'public' in view else self.nc.group.role_set.filter(name='member').first().person |
| 969 | + who = self.plain_person if 'public' in view else self.member |
967 | 970 | login_testing_unauthorized(self, who.user.username, url) |
968 | 971 | response = self.client.get(url) |
969 | 972 | self.assertEqual(response.status_code, 200) |
970 | 973 | q = PyQuery(response.content) |
971 | 974 | self.assertTrue( '(Concluded)' in q('h1').text()) |
972 | 975 | self.assertTrue( 'closed' in q('.alert-warning').text()) |
973 | | - |
| 976 | + |
| 977 | + def test_acceptance_closed(self): |
| 978 | + today = datetime.date.today().strftime('%Y%m%d') |
| 979 | + pid = self.nc.position_set.first().nomineeposition_set.first().id |
| 980 | + url = reverse('nomcom_process_nomination_status', kwargs = { |
| 981 | + 'year' : self.nc.year(), |
| 982 | + 'nominee_position_id' : pid, |
| 983 | + 'state' : 'accepted', |
| 984 | + 'date' : today, |
| 985 | + 'hash' : get_hash_nominee_position(today,pid), |
| 986 | + }) |
| 987 | + response = self.client.get(url) |
| 988 | + self.assertEqual(response.status_code, 403) |
| 989 | + |
| 990 | + def test_can_view_but_cannot_edit_nomcom_settings(self): |
| 991 | + url = reverse('nomcom_edit_nomcom',kwargs={'year':self.nc.year() }) |
| 992 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 993 | + response = self.client.get(url) |
| 994 | + self.assertEqual(response.status_code, 200) |
| 995 | + response = self.client.post(url,{}) |
| 996 | + self.assertEqual(response.status_code, 403) |
| 997 | + |
| 998 | + def test_cannot_classify_feedback(self): |
| 999 | + url = reverse('nomcom_view_feedback_pending',kwargs={'year':self.nc.year() }) |
| 1000 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1001 | + provide_private_key_to_test_client(self) |
| 1002 | + response = self.client.get(url) |
| 1003 | + self.assertEqual(response.status_code, 403) |
| 1004 | + response = self.client.post(url,{}) |
| 1005 | + self.assertEqual(response.status_code, 403) |
| 1006 | + |
| 1007 | + def test_cannot_modify_nominees(self): |
| 1008 | + url = reverse('nomcom_private_index', kwargs={'year':self.nc.year()}) |
| 1009 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1010 | + response = self.client.get(url) |
| 1011 | + self.assertEqual(response.status_code, 200) |
| 1012 | + q = PyQuery(response.content) |
| 1013 | + self.assertFalse( q('#batch-action-form')) |
| 1014 | + test_data = {"action": "set_as_pending", |
| 1015 | + "selected": [1]} |
| 1016 | + response = self.client.post(url, test_data) |
| 1017 | + self.assertEqual(response.status_code, 200) |
| 1018 | + q = PyQuery(response.content) |
| 1019 | + self.assertTrue('not active' in q('.alert-warning').text() ) |
| 1020 | + |
| 1021 | + def test_email_pasting_closed(self): |
| 1022 | + url = reverse('nomcom_private_feedback_email', kwargs={'year':self.nc.year()}) |
| 1023 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1024 | + response = self.client.get(url) |
| 1025 | + self.assertEqual(response.status_code, 200) |
| 1026 | + q = PyQuery(response.content) |
| 1027 | + self.assertFalse( q('#paste-email-feedback-form')) |
| 1028 | + test_data = {"email_text": "some garbage text", |
| 1029 | + } |
| 1030 | + response = self.client.post(url, test_data) |
| 1031 | + self.assertEqual(response.status_code, 200) |
| 1032 | + q = PyQuery(response.content) |
| 1033 | + self.assertTrue('not active' in q('.alert-warning').text() ) |
| 1034 | + |
| 1035 | + def test_questionnaire_entry_closed(self): |
| 1036 | + url = reverse('nomcom_private_questionnaire', kwargs={'year':self.nc.year()}) |
| 1037 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1038 | + response = self.client.get(url) |
| 1039 | + self.assertEqual(response.status_code, 200) |
| 1040 | + q = PyQuery(response.content) |
| 1041 | + self.assertFalse( q('#questionnaireform')) |
| 1042 | + response = self.client.post(url, {}) |
| 1043 | + self.assertEqual(response.status_code, 200) |
| 1044 | + q = PyQuery(response.content) |
| 1045 | + self.assertTrue('not active' in q('.alert-warning').text() ) |
| 1046 | + |
| 1047 | + def _test_send_reminders_closed(self,rtype): |
| 1048 | + url = reverse('nomcom_send_reminder_mail', kwargs={'year':self.nc.year(),'type':rtype }) |
| 1049 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1050 | + response = self.client.get(url) |
| 1051 | + self.assertEqual(response.status_code, 200) |
| 1052 | + q = PyQuery(response.content) |
| 1053 | + self.assertFalse( q('#reminderform')) |
| 1054 | + response = self.client.post(url, {}) |
| 1055 | + self.assertEqual(response.status_code, 200) |
| 1056 | + q = PyQuery(response.content) |
| 1057 | + self.assertTrue('not active' in q('.alert-warning').text() ) |
| 1058 | + |
| 1059 | + def test_send_accept_reminders_closed(self): |
| 1060 | + self._test_send_reminders_closed('accept') |
| 1061 | + |
| 1062 | + def test_send_questionnaire_reminders_closed(self): |
| 1063 | + self._test_send_reminders_closed('questionnaire') |
| 1064 | + |
| 1065 | + def test_merge_closed(self): |
| 1066 | + url = reverse('nomcom_private_merge', kwargs={'year':self.nc.year()}) |
| 1067 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1068 | + response = self.client.get(url) |
| 1069 | + q = PyQuery(response.content) |
| 1070 | + self.assertFalse( q('#mergeform')) |
| 1071 | + response = self.client.post(url, {}) |
| 1072 | + self.assertEqual(response.status_code, 200) |
| 1073 | + q = PyQuery(response.content) |
| 1074 | + self.assertTrue('not active' in q('.alert-warning').text() ) |
| 1075 | + |
| 1076 | + def test_cannot_edit_position(self): |
| 1077 | + url = reverse('nomcom_edit_position',kwargs={'year':self.nc.year(),'position_id':self.nc.position_set.first().id}) |
| 1078 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1079 | + provide_private_key_to_test_client(self) |
| 1080 | + response = self.client.get(url) |
| 1081 | + self.assertEqual(response.status_code, 403) |
| 1082 | + response = self.client.post(url,{}) |
| 1083 | + self.assertEqual(response.status_code, 403) |
| 1084 | + |
| 1085 | + def test_cannot_add_position(self): |
| 1086 | + url = reverse('nomcom_add_position',kwargs={'year':self.nc.year()}) |
| 1087 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1088 | + provide_private_key_to_test_client(self) |
| 1089 | + response = self.client.get(url) |
| 1090 | + self.assertEqual(response.status_code, 403) |
| 1091 | + response = self.client.post(url,{}) |
| 1092 | + self.assertEqual(response.status_code, 403) |
| 1093 | + |
| 1094 | + def test_cannot_delete_position(self): |
| 1095 | + url = reverse('nomcom_remove_position',kwargs={'year':self.nc.year(),'position_id':self.nc.position_set.first().id}) |
| 1096 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1097 | + provide_private_key_to_test_client(self) |
| 1098 | + response = self.client.get(url) |
| 1099 | + self.assertEqual(response.status_code, 403) |
| 1100 | + response = self.client.post(url,{}) |
| 1101 | + self.assertEqual(response.status_code, 403) |
| 1102 | + |
| 1103 | + def test_can_view_but_not_edit_templates(self): |
| 1104 | + template = DBTemplateFactory.create(group=self.nc.group, |
| 1105 | + title='Test template', |
| 1106 | + path='/nomcom/'+self.nc.group.acronym+'/test', |
| 1107 | + variables='', |
| 1108 | + type_id='text', |
| 1109 | + content='test content') |
| 1110 | + url = reverse('nomcom_edit_template',kwargs={'year':self.nc.year(), 'template_id':template.id}) |
| 1111 | + login_testing_unauthorized(self, self.chair.user.username, url) |
| 1112 | + response = self.client.get(url) |
| 1113 | + self.assertEqual(response.status_code, 200) |
| 1114 | + q = PyQuery(response.content) |
| 1115 | + self.assertFalse( q('#templateform') ) |
| 1116 | + |
0 commit comments