Esempio n. 1
0
 def test_add_denial(self, send_response_email_patch):
     with flask_login_user(self.admin_860):
         add_denial(self.request.id, self.denial_reasons, self.email_content)
         send_response_email_patch.assert_called_once_with(
             self.request.id,
             response_privacy.RELEASE_AND_PUBLIC,
             self.email_content,
             'Request {} Closed'.format(self.request.id)
         )
     response = self.request.responses.join(Determinations).filter(
         Determinations.dtype == determination_type.DENIAL).one()
     self.assertEqual(
         [
             response.request_id,
             response.privacy,
             response.dtype,
             response.reason
         ],
         [
             self.request.id,
             response_privacy.RELEASE_AND_PUBLIC,
             determination_type.DENIAL,
             format_determination_reasons(self.denial_reasons)
         ]
     )
     self.assert_response_event(self.request.id, event_type.REQ_CLOSED, response, self.admin_860)
Esempio n. 2
0
 def test_add_closing(self, send_response_email_patch):
     with flask_login_user(self.admin_860):
         self.request.acknowledge(days=30)
         self.request.set_agency_request_summary('blah')
         self.request.set_agency_request_summary_privacy(False)
         add_closing(self.request.id, self.closing_reasons, self.email_content)
         send_response_email_patch.assert_called_once_with(
             self.request.id,
             response_privacy.RELEASE_AND_PUBLIC,
             self.email_content,
             'Request {} Closed'.format(self.request.id)
         )
     response = self.request.responses.join(Determinations).filter(
         Determinations.dtype == determination_type.CLOSING).one()
     self.assertEqual(
         [
             response.request_id,
             response.privacy,
             response.dtype,
             response.reason
         ],
         [
             self.request.id,
             response_privacy.RELEASE_AND_PUBLIC,
             determination_type.CLOSING,
             format_determination_reasons(self.closing_reasons)
         ]
     )
     self.assert_response_event(self.request.id, event_type.REQ_CLOSED, response, self.admin_860)
Esempio n. 3
0
 def test_add_closing_file_release_public(self, send_response_email_patch):
     request_title_public = self.rf_agency_860.create_request_as_public_user(title_privacy=False)
     with flask_login_user(self.admin_860):
         request_title_public.acknowledge(days=30)
         request_title_public.add_file(privacy=response_privacy.RELEASE_AND_PUBLIC)
         add_closing(request_title_public.id, self.closing_reasons, self.email_content)
         send_response_email_patch.assert_called_once_with(
             request_title_public.id,
             response_privacy.RELEASE_AND_PUBLIC,
             self.email_content,
             'Request {} Closed'.format(request_title_public.id)
         )
     response = request_title_public.responses.join(Determinations).filter(
         Determinations.dtype == determination_type.CLOSING).one()
     self.assertEqual(
         [
             response.request_id,
             response.privacy,
             response.dtype,
             response.reason
         ],
         [
             request_title_public.id,
             response_privacy.RELEASE_AND_PUBLIC,
             determination_type.CLOSING,
             format_determination_reasons(self.closing_reasons)
         ]
     )
     self.assert_response_event(request_title_public.id, event_type.REQ_CLOSED, response, self.admin_860)
Esempio n. 4
0
    def test_create_contact_record_public(self, send_contact_email_patch):
        request = self.rf.create_request_as_public_user()
        user = self.rf.public_user
        subject = 'Inquire about {}'.format(request.id)
        message = 'I need more information about my request.'
        body = "Name: {} {}\n\nEmail: {}\n\nSubject: {}\n\nMessage:\n{}".format(
            user.first_name, user.last_name, user.email, subject, message)
        agency_emails = get_agency_emails(request.id)

        with flask_login_user(user):
            create_contact_record(request,
                                  user.first_name,
                                  user.last_name,
                                  user.email,
                                  subject,
                                  message)
            send_contact_email_patch.assert_called_once_with(
                subject,
                agency_emails,
                message,
                user.email
            )
        email_obj = Emails.query.filter(Emails.request_id == request.id,
                                        Emails.subject == subject).one()
        self.assertEqual(
            [
                [email_obj.to],
                email_obj.body
            ],
            [
                agency_emails,
                body
            ]
        )

        contact_event = Events.query.filter_by(response_id=email_obj.id).one()
        self.assertEqual(
            [
                contact_event.request_id,
                contact_event.user_guid,
                contact_event.auth_user_type,
                contact_event.type,
                contact_event.new_value
            ],
            [
                request.id,
                user.guid,
                user.auth_user_type,
                event_type.CONTACT_EMAIL_SENT,
                email_obj.val_for_events
            ]
        )
Esempio n. 5
0
 def test_add_denial_already_closed(self):
     with flask_login_user(self.admin_860):
         self.request.close()
         with self.assertRaises(UserRequestException):
             add_denial(self.request.id, self.denial_reasons, self.email_content)
Esempio n. 6
0
 def test_add_denial_invalid_request(self):
     with flask_login_user(self.admin_860):
         with self.assertRaises(NoResultFound):
             add_denial('FOIL-2017-002-00001', self.denial_reasons, self.email_content)
Esempio n. 7
0
 def test_add_closing_file_private(self):
     with flask_login_user(self.admin_860):
         self.request.acknowledge(days=30)
         self.request.add_file()
         with self.assertRaises(UserRequestException):
             add_closing(self.request.id, self.closing_reasons, self.email_content)
Esempio n. 8
0
 def test_add_closing_no_agency_request_summary(self):
     with flask_login_user(self.admin_860):
         self.request.acknowledge(days=30)
         with self.assertRaises(UserRequestException):
             add_closing(self.request.id, self.closing_reasons, self.email_content)
Esempio n. 9
0
 def test_add_closing_not_acknowledged(self):
     with flask_login_user(self.admin_860):
         self.request.close()
         with self.assertRaises(UserRequestException):
             add_closing(self.request.id, self.closing_reasons, self.email_content)