コード例 #1
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)
コード例 #2
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)
コード例 #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_process.py プロジェクト: wilsonc86/ledger
    def test_issued_status_after_entering_condition(self):
        """
        Test that if an application has been issued, entering condition leave the status as issued
        @see https://kanboard.dpaw.wa.gov.au/?controller=TaskViewController&action=show&task_id=2736&project_id=24
        """
        application = create_and_lodge_application(self.user)
        # set some conditions
        url = reverse('wl_applications:enter_conditions', args=[application.pk])
        condition = get_or_create_condition('0001', {"text": "For unit test"})
        data = {
            'conditionID': [condition.pk]
        }
        self.client.login(self.officer.email)
        self.assertTrue(is_client_authenticated(self.client))
        resp = self.client.post(url, data=data, follow=True)
        self.assertEquals(200, resp.status_code)
        application.refresh_from_db()
        self.assertEquals(application.processing_status, 'ready_to_issue')

        # issue licence
        url = reverse('wl_applications:issue_licence', args=[application.pk])
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        data = {
            'regions': [G(Region).pk],
            'return_frequency': -1,
            'issue_date': str(today),
            'start_date': str(today),
            'end_date': str(tomorrow)
        }
        resp = self.client.post(url, data=data, follow=True)
        self.assertEquals(200, resp.status_code)
        application.refresh_from_db()
        self.assertEquals(application.processing_status, 'issued')

        # now repost conditions
        url = reverse('wl_applications:enter_conditions', args=[application.pk])
        condition = get_or_create_condition('0001', {"text": "For unit test"})
        data = {
            'conditionID': [condition.pk]
        }
        resp = self.client.post(url, data=data, follow=True)
        self.assertEquals(200, resp.status_code)
        application.refresh_from_db()
        # status should not be 'ready_to_issue' but 'issued'
        expected_status = 'issued'
        self.assertEquals(application.processing_status, expected_status)
コード例 #6
0
    def test_issued_status_after_entering_condition(self):
        """
        Test that if an application has been issued, entering condition leave the status as issued
        @see https://kanboard.dpaw.wa.gov.au/?controller=TaskViewController&action=show&task_id=2736&project_id=24
        """
        application = create_and_lodge_application(self.user)
        # set some conditions
        url = reverse('wl_applications:enter_conditions', args=[application.pk])
        condition = get_or_create_condition('0001', {"text": "For unit test"})
        data = {
            'conditionID': [condition.pk]
        }
        self.client.login(self.officer.email)
        self.assertTrue(is_client_authenticated(self.client))
        resp = self.client.post(url, data=data, follow=True)
        self.assertEquals(200, resp.status_code)
        application.refresh_from_db()
        self.assertEquals(application.processing_status, 'ready_to_issue')

        # issue licence
        url = reverse('wl_applications:issue_licence', args=[application.pk])
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        data = {
            'regions': [G(Region).pk],
            'return_frequency': -1,
            'issue_date': str(today),
            'start_date': str(today),
            'end_date': str(tomorrow)
        }
        resp = self.client.post(url, data=data, follow=True)
        self.assertEquals(200, resp.status_code)
        application.refresh_from_db()
        self.assertEquals(application.processing_status, 'issued')

        # now repost conditions
        url = reverse('wl_applications:enter_conditions', args=[application.pk])
        condition = get_or_create_condition('0001', {"text": "For unit test"})
        data = {
            'conditionID': [condition.pk]
        }
        resp = self.client.post(url, data=data, follow=True)
        self.assertEquals(200, resp.status_code)
        application.refresh_from_db()
        # status should not be 'ready_to_issue' but 'issued'
        expected_status = 'issued'
        self.assertEquals(application.processing_status, expected_status)
コード例 #7
0
    def test_cannot_discard(self):
        """
        Test that an application cannot be discarded if it hasn't been pushed back to the applicant.
        Formally its processing status must be in the list of Application.CUSTOMER_DISCARDABLE_STATE
        :return:
        """
        # lodge application
        application = helpers.create_and_lodge_application(self.applicant)
        self.assertFalse(application.is_discardable)

        # try to discard with get or post
        previous_processing_status = application.processing_status
        previous_customer_status = application.customer_status
        url = reverse('wl_applications:discard_application',
                      args=[application.pk])
        self.client.login(self.applicant.email)
        self.assertTrue(is_client_authenticated(self.client))
        resp = self.client.get(url, follow=True)
        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)
        # the response should have an error message
        self.assertTrue(has_response_error_messages(resp))

        # same with post method
        resp = self.client.post(url, follow=True)
        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)
        # the response should have an error message
        self.assertTrue(has_response_error_messages(resp))
コード例 #8
0
ファイル: test_entry.py プロジェクト: wilsonc86/ledger
    def test_cannot_discard(self):
        """
        Test that an application cannot be discarded if it hasn't been pushed back to the applicant.
        Formally its processing status must be in the list of Application.CUSTOMER_DISCARDABLE_STATE
        :return:
        """
        # lodge application
        application = helpers.create_and_lodge_application(self.applicant)
        self.assertFalse(application.is_discardable)

        # try to discard with get or post
        previous_processing_status = application.processing_status
        previous_customer_status = application.customer_status
        url = reverse('wl_applications:discard_application', args=[application.pk])
        self.client.login(self.applicant.email)
        self.assertTrue(is_client_authenticated(self.client))
        resp = self.client.get(url, follow=True)
        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)
        # the response should have an error message
        self.assertTrue(has_response_error_messages(resp))

        # same with post method
        resp = self.client.post(url, follow=True)
        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)
        # the response should have an error message
        self.assertTrue(has_response_error_messages(resp))