Example #1
0
    def test_id_update(self):
        """
        Test that when an ID update is required and the users update their ID the customer and id status are correctly
         updated
        """
        application = create_and_lodge_application(self.user)
        self.client.login(self.officer.email)
        self.assertTrue(is_client_authenticated(self.client))
        clear_mailbox()
        data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': IDRequest.REASON_CHOICES[0][0],
            'text': 'you to upload an ID.'
        }
        url = reverse('wl_applications:id_request')
        self.assertFalse(is_email())
        response = self.client.post(url, data)
        self.assertEqual(200, response.status_code)
        resp_data = json.loads(response.content.decode('utf8'))
        self.assertIn('id_check_status', resp_data)
        self.assertIn('processing_status', resp_data)
        application.refresh_from_db()
        self.assertEqual('id_required', application.customer_status)
        self.assertEqual('awaiting_update', application.id_check_status)
        self.assertEqual('awaiting_applicant_response',
                         application.processing_status)
        self.assertTrue(is_email())
        email = get_email()
        self.assertIn(application.applicant_profile.email, email.to)
        self.assertEqual(ApplicationIDUpdateRequestedEmail.subject,
                         email.subject)

        # now user upload ID
        self.client.logout()
        self.assertIsNone(self.user.identification)
        self.client.login(self.user.email)
        self.assertTrue(is_client_authenticated(self.client))
        self.client.get(reverse('wl_main:identification'))
        upload_id(self.user)
        self.user.refresh_from_db()
        self.assertIsNotNone(self.user.identification)
        application.refresh_from_db()
        self.assertEqual('updated', application.id_check_status)
        self.assertEqual('under_review', application.customer_status)
        self.assertEqual('ready_for_action', application.processing_status)
Example #2
0
    def test_id_update(self):
        """
        Test that when an ID update is required and the users update their ID the customer and id status are correctly
         updated
        """
        application = create_and_lodge_application(self.user)
        self.client.login(self.officer.email)
        self.assertTrue(is_client_authenticated(self.client))
        clear_mailbox()
        data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': IDRequest.REASON_CHOICES[0][0],
            'text': 'you to upload an ID.'
        }
        url = reverse('wl_applications:id_request')
        self.assertFalse(is_email())
        response = self.client.post(url, data)
        self.assertEqual(200, response.status_code)
        resp_data = json.loads(response.content.decode('utf8'))
        self.assertIn('id_check_status', resp_data)
        self.assertIn('processing_status', resp_data)
        application.refresh_from_db()
        self.assertEqual('id_required', application.customer_status)
        self.assertEqual('awaiting_update', application.id_check_status)
        self.assertEqual('awaiting_applicant_response', application.processing_status)
        self.assertTrue(is_email())
        email = get_email()
        self.assertIn(application.applicant_profile.email, email.to)
        self.assertEqual(ApplicationIDUpdateRequestedEmail.subject, email.subject)

        # now user upload ID
        self.client.logout()
        self.assertIsNone(self.user.identification)
        self.client.login(self.user.email)
        self.assertTrue(is_client_authenticated(self.client))
        self.client.get(reverse('wl_main:identification'))
        upload_id(self.user)
        self.user.refresh_from_db()
        self.assertIsNotNone(self.user.identification)
        application.refresh_from_db()
        self.assertEqual('updated', application.id_check_status)
        self.assertEqual('under_review', application.customer_status)
        self.assertEqual('ready_for_action', application.processing_status)
Example #3
0
 def test_subject_max_length(self):
     """Test that a long subject is shorten"""
     email = TemplateEmailBase()
     subject = 'A verrrrrrrryyyyyyyyyyyyyyyyyy loooooooooooooooooooooooooooooooooooooooong subbbbbbbbbjjjjjjjjjjeeeeeect'
     email.subject = subject
     self.assertTrue(len(subject) > MAX_SUBJECT_LENGTH)
     self.assertFalse(helpers.is_email())
     email.send(['*****@*****.**'])
     emails = helpers.get_emails()
     self.assertEqual(len(emails), 1)
     email = emails[0]
     self.assertEqual(len(email.subject), MAX_SUBJECT_LENGTH)
     expected_subject = '{}..'.format(subject[:MAX_SUBJECT_LENGTH - 2])
     self.assertEqual(email.subject, expected_subject)
Example #4
0
 def test_subject_max_length(self):
     """Test that a long subject is shorten"""
     email = TemplateEmailBase()
     subject = 'A verrrrrrrryyyyyyyyyyyyyyyyyy loooooooooooooooooooooooooooooooooooooooong subbbbbbbbbjjjjjjjjjjeeeeeect'
     email.subject = subject
     self.assertTrue(len(subject) > MAX_SUBJECT_LENGTH)
     self.assertFalse(helpers.is_email())
     email.send(['*****@*****.**'])
     emails = helpers.get_emails()
     self.assertEqual(len(emails), 1)
     email = emails[0]
     self.assertEqual(len(email.subject), MAX_SUBJECT_LENGTH)
     expected_subject = '{}..'.format(subject[:MAX_SUBJECT_LENGTH - 2])
     self.assertEqual(email.subject, expected_subject)
Example #5
0
    def test_application_amendment(self):
        """
        Test that when an amendment is required, the user receives an email and can amend their application. When the
        user relodged, the officer can see the amendment and set the review status accordingly.
        """
        application = create_and_lodge_application(self.user)
        self.assertFalse(application.can_user_edit)

        self.client.login(self.officer.email)

        post_data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': AmendmentRequest.REASON_CHOICES[0][0],
            'text': 'Application needs more data'
        }

        response = self.client.post(reverse('wl_applications:amendment_request'), post_data)

        self.assertEqual(200, response.status_code)

        resp_data = json.loads(response.content.decode('utf8'))

        application.refresh_from_db()

        self.assertIn('review_status', resp_data)
        self.assertEquals(resp_data['review_status'], utils.REVIEW_STATUSES[application.review_status])
        self.assertIn('processing_status', resp_data)
        self.assertEquals(resp_data['processing_status'], utils.PROCESSING_STATUSES[application.processing_status])

        self.assertEqual(application.customer_status, 'amendment_required')
        self.assertEqual(application.processing_status, 'awaiting_applicant_response')
        self.assertEqual(application.review_status, 'awaiting_amendments')

        amendment_request = AmendmentRequest.objects.filter(application=application).first()

        self.assertIsNotNone(amendment_request)

        self.assertEquals(amendment_request.status, 'requested')

        self.assertTrue(is_email())
        email = get_email()
        self.assertIn(application.applicant_profile.email, email.to)
        self.assertEqual(ApplicationAmendmentRequestedEmail.subject, email.subject)

        # user logs in
        self.client.logout()
        self.client.login(self.user.email)

        self.assertTrue(application.can_user_edit)

        response = self.client.get(reverse('wl_applications:edit_application', args=(application.pk,)), follow=True)

        # check that client will be redirected to the enter details page
        self.assertRedirects(response, reverse('wl_applications:enter_details'), status_code=302,
                             target_status_code=200)

        # edit and resubmit data
        post_params = {
            'project_title-0-0': 'New Title',
            'lodge': True
        }

        response = self.client.post(reverse('wl_applications:enter_details'), post_params)

        # check that client is redirected to preview
        self.assertRedirects(response, reverse('wl_applications:preview'),
                             status_code=302, target_status_code=200, fetch_redirect_response=False)

        response = self.client.post(reverse('wl_applications:preview'))

        # FIXME: simulate full checkout process instead of skipping
        self.client.get(reverse('wl_applications:complete'))

        application.refresh_from_db()

        self.assertFalse(application.can_user_edit)

        self.assertEqual(application.data[0]['project_details'][0]['project_title'], 'New Title')

        self.assertEqual(application.customer_status, 'under_review')
        self.assertEqual(application.processing_status, 'ready_for_action')
        self.assertEqual(application.review_status, 'amended')

        amendment_request.refresh_from_db()

        self.assertEquals(amendment_request.status, 'amended')

        # officer logs in
        self.client.logout()
        self.client.login(self.officer.email)

        post_data = {
            'applicationID': application.id,
            'status': 'accepted'
        }

        response = self.client.post(reverse('wl_applications:set_review_status'), post_data)

        self.assertEquals(response.status_code, 200)

        application.refresh_from_db()

        self.assertEquals(application.review_status, 'accepted')
Example #6
0
    def test_application_amendment(self):
        """
        Test that when an amendment is required, the user receives an email and can amend their application. When the
        user relodged, the officer can see the amendment and set the review status accordingly.
        """
        application = create_and_lodge_application(self.user)
        self.assertFalse(application.can_user_edit)

        self.client.login(self.officer.email)

        post_data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': AmendmentRequest.REASON_CHOICES[0][0],
            'text': 'Application needs more data'
        }

        response = self.client.post(
            reverse('wl_applications:amendment_request'), post_data)

        self.assertEqual(200, response.status_code)

        resp_data = json.loads(response.content.decode('utf8'))

        application.refresh_from_db()

        self.assertIn('review_status', resp_data)
        self.assertEquals(resp_data['review_status'],
                          utils.REVIEW_STATUSES[application.review_status])
        self.assertIn('processing_status', resp_data)
        self.assertEquals(
            resp_data['processing_status'],
            utils.PROCESSING_STATUSES[application.processing_status])

        self.assertEqual(application.customer_status, 'amendment_required')
        self.assertEqual(application.processing_status,
                         'awaiting_applicant_response')
        self.assertEqual(application.review_status, 'awaiting_amendments')

        amendment_request = AmendmentRequest.objects.filter(
            application=application).first()

        self.assertIsNotNone(amendment_request)

        self.assertEquals(amendment_request.status, 'requested')

        self.assertTrue(is_email())
        email = get_email()
        self.assertIn(application.applicant_profile.email, email.to)
        self.assertEqual(ApplicationAmendmentRequestedEmail.subject,
                         email.subject)

        # user logs in
        self.client.logout()
        self.client.login(self.user.email)

        self.assertTrue(application.can_user_edit)

        response = self.client.get(reverse('wl_applications:edit_application',
                                           args=(application.pk, )),
                                   follow=True)

        # check that client will be redirected to the enter details page
        self.assertRedirects(response,
                             reverse('wl_applications:enter_details'),
                             status_code=302,
                             target_status_code=200)

        # edit and resubmit data
        post_params = {'project_title-0-0': 'New Title', 'lodge': True}

        response = self.client.post(reverse('wl_applications:enter_details'),
                                    post_params)

        # check that client is redirected to preview
        self.assertRedirects(response,
                             reverse('wl_applications:preview'),
                             status_code=302,
                             target_status_code=200,
                             fetch_redirect_response=False)

        response = self.client.post(reverse('wl_applications:preview'))

        # FIXME: simulate full checkout process instead of skipping
        self.client.get(reverse('wl_applications:complete'))

        application.refresh_from_db()

        self.assertFalse(application.can_user_edit)

        self.assertEqual(
            application.data[0]['project_details'][0]['project_title'],
            'New Title')

        self.assertEqual(application.customer_status, 'under_review')
        self.assertEqual(application.processing_status, 'ready_for_action')
        self.assertEqual(application.review_status, 'amended')

        amendment_request.refresh_from_db()

        self.assertEquals(amendment_request.status, 'amended')

        # officer logs in
        self.client.logout()
        self.client.login(self.officer.email)

        post_data = {'applicationID': application.id, 'status': 'accepted'}

        response = self.client.post(
            reverse('wl_applications:set_review_status'), post_data)

        self.assertEquals(response.status_code, 200)

        application.refresh_from_db()

        self.assertEquals(application.review_status, 'accepted')