def test_response_denial(self): with self.client as client: login_user_with_client(client, self.admin_860.get_id()) response = self.client.post( '/response/denial/' + self.request.id, data={ "reasons": ['1', '2', '3'], "email-summary": 'This is a email summary' } ) self.assertEqual(response.status_code, 302) self.assertEqual(urlparse(response.location).path, url_for('request.view', request_id=self.request.id))
def test_response_denial_missing_reasons(self): with self.client as client: login_user_with_client(client, self.admin_860.get_id()) response = self.client.post( '/response/denial/' + self.request.id, data={ "email-summary": 'This is a email summary' } ) self.assert_flashes(expected_message='Uh Oh, it looks like the denial reasons is missing! ' 'This is probably NOT your fault.', expected_category='danger') self.assertEqual(response.status_code, 302) self.assertEqual(urlparse(response.location).path, url_for('request.view', request_id=self.request.id))
def test_response_closing_no_agency_request_summary(self): self.request.acknowledge(days=30) with self.client as client: login_user_with_client(client, self.admin_860.get_id()) response = self.client.post( '/response/closing/' + self.request.id, data={ "reasons": ['1', '2', '3'], "email-summary": 'This is a email summary' } ) self.assert_flashes(expected_message='Unable to close request:', expected_category='danger') self.assertEqual(response.status_code, 302) self.assertEqual(urlparse(response.location).path, url_for('request.view', request_id=self.request.id))
def test_response_closing(self): self.request.acknowledge(days=30) self.request.set_agency_request_summary(agency_request_summary='blah') self.request.set_agency_request_summary_privacy(privacy=False) with self.client as client: login_user_with_client(client, self.admin_860.get_id()) response = self.client.post( '/response/closing/' + self.request.id, data={ "reasons": ['1', '2', '3'], "email-summary": 'This is a email summary' } ) self.assertEqual(response.status_code, 302) self.assertEqual(urlparse(response.location).path, url_for('request.view', request_id=self.request.id))
def test_view_all_agency(self, render_template_patch, search_requests_form_patch): """ Test render_template in request.views.view_all is called once for logged in agency user. """ # login agency_user with self.client as client: login_user_with_client(client, self.agency_admin.get_id()) self.client.get('/request/view_all') render_template_patch.assert_called_once_with( 'request/all.html', form=search_requests_form_patch(), holidays=sorted(get_holidays_date_list( datetime.utcnow().year, (datetime.utcnow() + rd(years=DEFAULT_YEARS_HOLIDAY_LIST)).year) ) )