コード例 #1
0
ファイル: test_returns.py プロジェクト: mintcoding/ledger
    def test_curate_request_amendments(self):
        """
        Test workflow when an officer requests a amendment to a return, especially the status change and verify that
        an email is sent to the user.
        """
        ret, data = self._create_and_lodge_return()
        expected_status = 'submitted'
        self.assertEqual(ret.status, expected_status)

        pending_amendments = ret.pending_amendments_qs
        self.assertEqual(pending_amendments.count(), 0)

        url = reverse('wl_returns:amendment_request')
        curator = self.officer
        self.client.login(curator.email)
        # important clear mailbox
        clear_mailbox()
        self.assertEqual(len(mail.outbox), 0)

        payload = {
            'ret': ret.pk,
            'officer': curator.pk,
            'reason': 'Chubby bat is not a valid species'
        }
        resp = self.client.post(url, data=payload)
        self.assertEqual(resp.status_code, 200)
        # expect a json response with the return amendment serialized
        resp_data = resp.json()
        self.assertTrue('amendment_request' in resp_data)
        # the reason should be returned
        self.assertEqual(resp_data['amendment_request'].get('reason'),
                         payload['reason'])

        ret.refresh_from_db()
        expected_status = 'amendment_required'
        self.assertEqual(ret.status, expected_status)

        # we should have a pending amendment
        pending_amendments = ret.pending_amendments_qs
        self.assertEqual(pending_amendments.count(), 1)
        pending_amendment = pending_amendments.first()
        self.assertEqual(pending_amendment.status, 'requested')
        self.assertEqual(pending_amendment.officer, curator)
        self.assertEqual(pending_amendment.reason, payload['reason'])
        self.assertEqual(pending_amendment.ret, ret)

        # an email must have been sent to the applicant
        self.assertEqual(len(mail.outbox), 1)
        email = mail.outbox[0]
        self.assertEqual(len(email.to), 1)
        expected_address = ret.licence.profile.email
        self.assertEqual(email.to[0], expected_address)
        # the email body should contain a link to the edit return page
        # due to test environment we cannot use reverse or even host_reverse
        expected_url = "/returns/enter-return/{}".format(ret.pk)
        self.assertTrue(str(email.body).find(expected_url) > 0)
コード例 #2
0
ファイル: test_returns.py プロジェクト: wilsonc86/ledger
    def test_curate_request_amendments(self):
        """
        Test workflow when an officer requests a amendment to a return, especially the status change and verify that
        an email is sent to the user.
        """
        ret, data = self._create_and_lodge_return()
        expected_status = 'submitted'
        self.assertEqual(ret.status, expected_status)

        pending_amendments = ret.pending_amendments_qs
        self.assertEqual(pending_amendments.count(), 0)

        url = reverse('wl_returns:amendment_request')
        curator = self.officer
        self.client.login(curator.email)
        # important clear mailbox
        clear_mailbox()
        self.assertEqual(len(mail.outbox), 0)

        payload = {
            'ret': ret.pk,
            'officer': curator.pk,
            'reason': 'Chubby bat is not a valid species'
        }
        resp = self.client.post(url, data=payload)
        self.assertEqual(resp.status_code, 200)
        # expect a json response with the return amendment serialized
        resp_data = resp.json()
        self.assertTrue('amendment_request' in resp_data)
        # the reason should be returned
        self.assertEqual(resp_data['amendment_request'].get('reason'), payload['reason'])

        ret.refresh_from_db()
        expected_status = 'amendment_required'
        self.assertEqual(ret.status, expected_status)

        # we should have a pending amendment
        pending_amendments = ret.pending_amendments_qs
        self.assertEqual(pending_amendments.count(), 1)
        pending_amendment = pending_amendments.first()
        self.assertEqual(pending_amendment.status, 'requested')
        self.assertEqual(pending_amendment.officer, curator)
        self.assertEqual(pending_amendment.reason, payload['reason'])
        self.assertEqual(pending_amendment.ret, ret)

        # an email must have been sent to the applicant
        self.assertEqual(len(mail.outbox), 1)
        email = mail.outbox[0]
        self.assertEqual(len(email.to), 1)
        expected_address = ret.licence.profile.email
        self.assertEqual(email.to[0], expected_address)
        # the email body should contain a link to the edit return page
        # due to test environment we cannot use reverse or even host_reverse
        expected_url = "/returns/enter-return/{}".format(ret.pk)
        self.assertTrue(str(email.body).find(expected_url) > 0)
コード例 #3
0
    def test_pushed_back_application_discarded_not_deleted(self):
        # lodge application
        application = helpers.create_and_lodge_application(self.applicant)
        self.assertFalse(application.is_discardable)
        # officer request amendment
        url = reverse('wl_applications:amendment_request')
        self.client.login(self.officer.email)
        resp = self.client.post(url,
                                data={
                                    'application': application.pk,
                                    'officer': self.officer.pk,
                                    'reason': 'missing_information'
                                })
        self.assertEquals(resp.status_code, 200)
        application.refresh_from_db()
        # application should now be discardable
        self.assertTrue(application.is_discardable)
        # but not deletable
        self.assertFalse(application.is_deletable)

        # discard
        self.client.logout()
        clear_mailbox()
        self.client.login(self.applicant.email)
        self.assertTrue(is_client_authenticated(self.client))
        url = reverse('wl_applications:discard_application',
                      args=[application.pk])
        # the get should not discard but return a confirm page
        previous_processing_status = application.processing_status
        previous_customer_status = application.customer_status
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 200)
        # test that there's a cancel_url in the context of the response and an action_url that is set to the proper url
        self.assertTrue('cancel_url' in resp.context)
        self.assertEqual(resp.context['cancel_url'],
                         reverse('wl_dashboard:home'))
        self.assertTrue('action_url' in resp.context)
        self.assertEquals(resp.context['action_url'], url)
        application.refresh_from_db()
        # status should be unchanged
        self.assertNotEqual(application.processing_status, 'discarded')
        self.assertNotEqual(application.customer_status, 'discarded')
        self.assertEqual(application.processing_status,
                         previous_processing_status)
        self.assertEqual(application.customer_status, previous_customer_status)

        # actual discard
        resp = self.client.post(url, data=None, follow=True)
        self.assertEquals(resp.status_code, 200)
        application.refresh_from_db()
        self.assertEqual(application.processing_status, 'discarded')
        self.assertEqual(application.customer_status, 'discarded')
        # there should be a message
        self.assertTrue(has_response_messages(resp))
        self.assertFalse(has_response_error_messages(resp))
コード例 #4
0
ファイル: test_entry.py プロジェクト: wilsonc86/ledger
    def test_pushed_back_application_discarded_not_deleted(self):
        # lodge application
        application = helpers.create_and_lodge_application(self.applicant)
        self.assertFalse(application.is_discardable)
        # officer request amendment
        url = reverse('wl_applications:amendment_request')
        self.client.login(self.officer.email)
        resp = self.client.post(url, data={
            'application': application.pk,
            'officer': self.officer.pk,
            'reason': 'missing_information'
        })
        self.assertEquals(resp.status_code, 200)
        application.refresh_from_db()
        # application should now be discardable
        self.assertTrue(application.is_discardable)
        # but not deletable
        self.assertFalse(application.is_deletable)

        # discard
        self.client.logout()
        clear_mailbox()
        self.client.login(self.applicant.email)
        self.assertTrue(is_client_authenticated(self.client))
        url = reverse('wl_applications:discard_application', args=[application.pk])
        # the get should not discard but return a confirm page
        previous_processing_status = application.processing_status
        previous_customer_status = application.customer_status
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 200)
        # test that there's a cancel_url in the context of the response and an action_url that is set to the proper url
        self.assertTrue('cancel_url' in resp.context)
        self.assertEqual(resp.context['cancel_url'], reverse('wl_dashboard:home'))
        self.assertTrue('action_url' in resp.context)
        self.assertEquals(resp.context['action_url'], url)
        application.refresh_from_db()
        # status should be unchanged
        self.assertNotEqual(application.processing_status, 'discarded')
        self.assertNotEqual(application.customer_status, 'discarded')
        self.assertEqual(application.processing_status, previous_processing_status)
        self.assertEqual(application.customer_status, previous_customer_status)

        # actual discard
        resp = self.client.post(url, data=None, follow=True)
        self.assertEquals(resp.status_code, 200)
        application.refresh_from_db()
        self.assertEqual(application.processing_status, 'discarded')
        self.assertEqual(application.customer_status, 'discarded')
        # there should be a message
        self.assertTrue(has_response_messages(resp))
        self.assertFalse(has_response_error_messages(resp))
コード例 #5
0
ファイル: test_conditions.py プロジェクト: wilsonc86/ledger
    def _issue_assessment(self, application, assessor_group):
        self.client.login(self.officer.email)

        url = reverse('wl_applications:send_for_assessment')
        payload = {
            'applicationID': application.pk,
            'assGroupID': assessor_group.pk
        }
        resp = self.client.post(url, data=payload)
        self.assertEqual(resp.status_code, 200)
        self.client.logout()
        clear_mailbox()
        data = resp.json()
        return Assessment.objects.filter(pk=data['assessment']['id']).first()
コード例 #6
0
ファイル: test_conditions.py プロジェクト: wilsonc86/ledger
    def _issue_assessment(self, application, assessor_group):
        self.client.login(self.officer.email)

        url = reverse('wl_applications:send_for_assessment')
        payload = {
            'applicationID': application.pk,
            'assGroupID': assessor_group.pk
        }
        resp = self.client.post(url, data=payload)
        self.assertEqual(resp.status_code, 200)
        self.client.logout()
        clear_mailbox()
        data = resp.json()
        return Assessment.objects.filter(pk=data['assessment']['id']).first()
コード例 #7
0
ファイル: test_process.py プロジェクト: scottp-dpaw/ledger
    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)
コード例 #8
0
ファイル: test_process.py プロジェクト: wilsonc86/ledger
    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)
コード例 #9
0
 def tearDown(self):
     self.client.logout()
     clear_mailbox()
コード例 #10
0
ファイル: test_process.py プロジェクト: wilsonc86/ledger
 def tearDown(self):
     self.client.logout()
     clear_mailbox()
     clear_all_id_files()
コード例 #11
0
ファイル: test_process.py プロジェクト: scottp-dpaw/ledger
 def tearDown(self):
     self.client.logout()
     clear_mailbox()
     clear_all_id_files()
コード例 #12
0
ファイル: tests.py プロジェクト: wilsonc86/ledger
 def setUp(self):
     helpers.clear_mailbox()
コード例 #13
0
ファイル: tests.py プロジェクト: wilsonc86/ledger
 def setUp(self):
     helpers.clear_mailbox()