def test_renew_licence(self): """ Testing that a user can renew a licence and restart the application process based on the previous licence's application data """ application = helpers.create_and_lodge_application(user=self.customer) licence = helpers.issue_licence(application, licence_data = { 'end_date': date.today() + relativedelta(days=30), 'is_renewable': True }) self.client.login(self.customer.email) response = self.client.get(reverse('wl_applications:renew_licence', args=(licence.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) self.assertNotEquals(application.id, response.context['application'].id) self.assertEquals(response.context['application'].application_type, 'renewal') # check that the data contained in the context is the same as the application data self.assertEquals(application.data, response.context['application'].data) helpers.delete_application_session(self.client) # check that a licence that isn't due to expire within 30 days is not cannot be renewed application = helpers.create_and_lodge_application(user=self.customer) licence = helpers.issue_licence(application, licence_data = { 'end_date': date.today() + relativedelta(days=31), 'is_renewable': True }) response = self.client.get(reverse('wl_applications:renew_licence', args=(licence.pk,)), follow=True) self.assertEqual(response.status_code, 403) # check that a licence that isn't renewable cannot be renewed application = helpers.create_and_lodge_application(user=self.customer) licence = helpers.issue_licence(application, licence_data = { 'end_date': date.today() + relativedelta(days=30), 'is_renewable': False }) response = self.client.get(reverse('wl_applications:renew_licence', args=(licence.pk,)), follow=True) self.assertEqual(response.status_code, 403)
def setUp(self): self.client = main_helpers.SocialClient() self.user = main_helpers.get_or_create_default_customer() self.officer = main_helpers.get_or_create_default_officer() self.assessor = main_helpers.get_or_create_default_assessor() self.lodged_application = app_helpers.create_and_lodge_application( self.user, **{'data': { 'title': 'Lodged Application' }}) self.issued_application = app_helpers.create_and_lodge_application( self.user, **{'data': { 'title': 'Issued Application' }}) self.licence = app_helpers.issue_licence(self.issued_application, self.officer) self.assertIsNotNone(self.licence) self.issue_urls_get = [ { 'url': reverse('wl_applications:issue_licence', args=[self.lodged_application.pk]), 'data': None }, { 'url': reverse('wl_applications:reissue_licence', args=[self.licence.pk]), 'data': None }, { 'url': reverse('wl_applications:preview_licence', args=[self.issued_application.pk]), 'data': app_helpers.get_minimum_data_for_issuing_licence() }, ] self.issue_urls_post = [ { 'url': reverse('wl_applications:issue_licence', args=[self.lodged_application.pk]), 'data': app_helpers.get_minimum_data_for_issuing_licence() }, ]
def _issue_licence(self, licence_data, **kwargs): application = app_helpers.create_and_lodge_application( self.customer, **{ 'applicant': kwargs.get('applicant', self.customer), 'licence_type': kwargs.get('licence_type', self.licence_type) }) self.assertIsNotNone(application) self.assertEqual(application.applicant, self.customer) self.assertIsNone(application.proxy_applicant) licence = app_helpers.issue_licence(application, kwargs.get('issuer', self.officer), licence_data=licence_data) self.assertEqual(licence.holder, self.customer) self.assertIsNotNone(licence) return licence
def _issue_licence(self, licence_data, **kwargs): application = app_helpers.create_and_lodge_application(self.customer, **{ 'applicant': kwargs.get('applicant', self.customer), 'licence_type': kwargs.get('licence_type', self.licence_type) }) self.assertIsNotNone(application) self.assertEqual(application.applicant, self.customer) self.assertIsNone(application.proxy_applicant) licence = app_helpers.issue_licence( application, kwargs.get('issuer', self.officer), licence_data=licence_data ) self.assertEqual(licence.holder, self.customer) self.assertIsNotNone(licence) return licence
def test_amend_licence(self): """ Testing that a user can amend a licence and restart the application process based on the previous licence's application data """ application = helpers.create_and_lodge_application(user=self.customer) licence = helpers.issue_licence(application) self.client.login(self.customer.email) response = self.client.get(reverse('wl_applications:amend_licence', args=(licence.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) self.assertNotEquals(application.id, response.context['application'].id) self.assertEquals(response.context['application'].application_type, 'amendment') # check that the data contained in the context is the same as the application data self.assertEquals(application.data, response.context['application'].data)
def setUp(self): self.client = main_helpers.SocialClient() self.user = main_helpers.get_or_create_default_customer() self.officer = main_helpers.get_or_create_default_officer() self.assessor = main_helpers.get_or_create_default_assessor() self.lodged_application = app_helpers.create_and_lodge_application(self.user, **{ 'data': { 'title': 'Lodged Application' } }) self.issued_application = app_helpers.create_and_lodge_application(self.user, **{ 'data': { 'title': 'Issued Application' } }) self.licence = app_helpers.issue_licence(self.issued_application, self.officer) self.assertIsNotNone(self.licence) self.issue_urls_get = [ { 'url': reverse('wl_applications:issue_licence', args=[self.lodged_application.pk]), 'data': None }, { 'url': reverse('wl_applications:reissue_licence', args=[self.licence.pk]), 'data': None }, { 'url': reverse('wl_applications:preview_licence', args=[self.issued_application.pk]), 'data': app_helpers.get_minimum_data_for_issuing_licence() }, ] self.issue_urls_post = [ { 'url': reverse('wl_applications:issue_licence', args=[self.lodged_application.pk]), 'data': app_helpers.get_minimum_data_for_issuing_licence() }, ]
def test_multiple_application_entry_denied(self): """ Testing the if a user is in the process of entering an application and attempts to start/edit/renew/amend another application, they are redirected back to home """ entry_denied_message = ('There is currently another application in the process of being entered. Please ' + 'conclude or save this application before creating a new one. If you are seeing this ' + 'message and there is not another application being entered, you may need to '+ '<a href="{}">logout</a> and log in again.').format(reverse('accounts:logout')) self.client.login(self.customer.email) response = self.client.get(reverse('wl_applications:new_application')) self.assertRedirects(response, reverse('wl_applications:select_licence_type'), status_code=302, target_status_code=200, fetch_redirect_response=False) # attempt to start another new licence application response = self.client.get(reverse('wl_applications:new_application'), follow=True) self.assertRedirects(response, reverse('wl_dashboard:tables_customer'), status_code=302, target_status_code=200, fetch_redirect_response=False) self.assertIn('messages', response.context) self.assertEquals(len(response.context['messages']), 1) self.assertEquals([str(m.message) for m in response.context['messages']][0], entry_denied_message) application = helpers.create_application(user=self.customer) # attempt to edit an application response = self.client.get(reverse('wl_applications:edit_application', args=(application.pk, )), follow=True) self.assertRedirects(response, reverse('wl_dashboard:tables_customer'), status_code=302, target_status_code=200, fetch_redirect_response=False) self.assertIn('messages', response.context) self.assertEquals(len(response.context['messages']), 1) self.assertEquals([str(m.message) for m in response.context['messages']][0], entry_denied_message) application = helpers.create_and_lodge_application(user=self.customer) licence = helpers.issue_licence(application, licence_data = { 'end_date': date.today() + relativedelta(days=30), 'is_renewable': True }) # attempt to renew a licence response = self.client.get(reverse('wl_applications:renew_licence', args=(licence.pk, )), follow=True) self.assertRedirects(response, reverse('wl_dashboard:tables_customer'), status_code=302, target_status_code=200, fetch_redirect_response=False) self.assertIn('messages', response.context) self.assertEquals(len(response.context['messages']), 1) self.assertEquals([str(m.message) for m in response.context['messages']][0], entry_denied_message) response = self.client.get(reverse('wl_applications:amend_licence', args=(licence.pk, )), follow=True ) # attempt to amend a licence self.assertRedirects(response, reverse('wl_dashboard:tables_customer'), status_code=302, target_status_code=200, fetch_redirect_response=False) self.assertIn('messages', response.context) self.assertEquals(len(response.context['messages']), 1) self.assertEquals([str(m.message) for m in response.context['messages']][0], entry_denied_message)