示例#1
0
    def test_summary_shows_correct_sections_on_export_details_entry(
            self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['has_exported_before'] = True
        fake_grant_application['has_exported_in_last_12_months'] = True
        fake_grant_application['export_regions'] = ['africa']
        fake_grant_application['markets_intending_on_exporting_to'] = [
            'existing'
        ]
        fake_grant_application['is_in_contact_with_dit_trade_advisor'] = False
        fake_grant_application[
            'export_experience_description'] = 'A description'
        fake_grant_application['export_strategy'] = 'A strategy'
        mocks[4].return_value = fake_grant_application

        response = self.client.get(self.url)
        html = BeautifulSoup(response.content, 'html.parser')
        headings = html.find_all(id='id_summary_list_heading')
        self.assertListEqual([h.text for h in headings], [
            PreviousApplicationsView.extra_context['page']['heading'],
            SelectAnEventView.extra_context['page']['heading'],
            EventCommitmentView.extra_context['page']['heading'],
            SelectCompanyView.extra_context['page']['heading'],
            CompanyDetailsView.extra_context['page']['heading'],
            ContactDetailsView.extra_context['page']['heading'],
            CompanyTradingDetailsView.extra_context['page']['heading'],
            ExportExperienceView.extra_context['page']['heading'],
            ExportDetailsView.extra_context['page']['heading'],
            TradeEventDetailsView.extra_context['page']['heading'],
            StateAidSummaryView.extra_context['page']['heading'],
        ])
示例#2
0
    def test_summary_shows_correct_sections_on_manual_company_entry(
            self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['company'] = None
        fake_grant_application['manual_company_type'] = 'limited company'
        fake_grant_application['manual_company_name'] = 'A Name'
        fake_grant_application['manual_company_address_line_1'] = 'Line 1'
        fake_grant_application['manual_company_address_line_2'] = 'Line 2'
        fake_grant_application['manual_company_address_town'] = 'Town 1'
        fake_grant_application['manual_company_address_county'] = 'County 1'
        fake_grant_application['manual_company_address_postcode'] = 'ZZ0 1ZZ'
        fake_grant_application['manual_time_trading_in_uk'] = '2 to 5 years'
        fake_grant_application['manual_registration_number'] = '12345678'
        fake_grant_application['manual_vat_number'] = '123456789'
        fake_grant_application['manual_website'] = 'www.test.com'
        mocks[4].return_value = fake_grant_application

        response = self.client.get(self.url)
        html = BeautifulSoup(response.content, 'html.parser')
        headings = html.find_all(id='id_summary_list_heading')
        self.assertListEqual([h.text for h in headings], [
            PreviousApplicationsView.extra_context['page']['heading'],
            SelectAnEventView.extra_context['page']['heading'],
            EventCommitmentView.extra_context['page']['heading'],
            ManualCompanyDetailsView.extra_context['page']['heading'],
            CompanyDetailsView.extra_context['page']['heading'],
            ContactDetailsView.extra_context['page']['heading'],
            CompanyTradingDetailsView.extra_context['page']['heading'],
            ExportExperienceView.extra_context['page']['heading'],
            TradeEventDetailsView.extra_context['page']['heading'],
            StateAidSummaryView.extra_context['page']['heading'],
        ])
示例#3
0
 def test_post_redirects_to_ineligible_if_application_is_not_active(
         self, *mocks):
     fake_grant_application = FAKE_GRANT_APPLICATION.copy()
     fake_grant_application['is_eligible'] = False
     mocks[1].return_value = fake_grant_application
     response = self.client.post(self.url)
     self.assertRedirects(response,
                          reverse('grant-applications:ineligible'))
示例#4
0
 def test_get_redirects_to_confirmation_if_application_already_sent_for_review(self, *mocks):
     fake_grant_application = FAKE_GRANT_APPLICATION.copy()
     fake_grant_application['sent_for_review'] = True
     mocks[1].return_value = fake_grant_application
     response = self.client.get(self.url)
     self.assertRedirects(
         response, reverse('grant-applications:confirmation', args=(self.gal.pk,))
     )
 def test_get_redirects_to_ineligible_if_application_is_not_active(
         self, *mocks):
     fake_grant_application = FAKE_GRANT_APPLICATION.copy()
     fake_grant_application['is_eligible'] = False
     mocks[3].return_value = fake_grant_application
     response = self.client.get(self.url, data={'search_term': 'hello'})
     self.assertRedirects(response,
                          reverse('grant-applications:ineligible'))
示例#6
0
 def test_post_redirect_to_export_details_on_true(self, *mocks):
     fake_grant_application = FAKE_GRANT_APPLICATION.copy()
     fake_grant_application['has_exported_before'] = True
     mocks[0].return_value = fake_grant_application
     response = self.client.post(self.url,
                                 data={'has_exported_before': True})
     self.assertRedirects(response,
                          reverse('grant-applications:export-details',
                                  args=(self.gal.pk, )),
                          fetch_redirect_response=False)
示例#7
0
    def test_get_does_not_redirect_to_ineligible_if_review_page_has_been_viewed(self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['is_eligible'] = False
        mocks[1].return_value = fake_grant_application

        self.gal.has_viewed_review_page = True
        self.gal.save()

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, PreviousApplicationsView.template_name)
示例#8
0
    def test_initial_when_no_event_is_set(self, *mocks):
        mocks[3].return_value = FAKE_GRANT_APPLICATION.copy()
        mocks[3].return_value['event'] = None

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)

        soup = BeautifulSoup(response.content, 'html.parser')
        all_event_radios = soup.find_all(
            attrs={'class': 'govuk-radios__input'})
        for event_radio in all_event_radios:
            self.assertNotIn('checked', event_radio.attrs)
    def test_back_url_export_details(self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['has_exported_before'] = True
        mocks[1].return_value = fake_grant_application

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, 200)
        back_html = BeautifulSoup(response.content,
                                  'html.parser').find(id='id_back_link')
        self.assertEqual(
            back_html.attrs['href'],
            reverse('grant-applications:export-details', args=(self.gal.pk, )))
    def test_get_does_not_redirect_to_ineligible_if_review_page_has_been_viewed(self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['is_eligible'] = False
        mocks[1].return_value = fake_grant_application

        self.gal.has_viewed_review_page = True
        self.gal.save()

        response = self.client.get(self.url)
        self.assertRedirects(
            response,
            reverse('grant-applications:state-aid-summary', args=(self.gal.pk,)),
            fetch_redirect_response=False
        )
示例#11
0
    def test_summary_export_experience_section_shows_single_row(self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['has_exported_before'] = True
        mocks[4].return_value = fake_grant_application

        response = self.client.get(self.url)
        html = BeautifulSoup(response.content,
                             'html.parser').find(id='id_summary_list_7')

        rows = html.find_all(attrs={'class': 'govuk-summary-list__row'})
        self.assertEqual(len(rows), 1)
        self.assertEqual(
            html.find(id='id_summary_list_key_0').text,
            ExportExperienceForm.base_fields['has_exported_before'].label)
        self.assertIsNone(html.find(id='id_summary_list_key_1'))
示例#12
0
    def test_post_redirects_to_export_page_if_application_review_page_has_been_viewed(
            self, *mocks):
        fake_grant_application = FAKE_GRANT_APPLICATION.copy()
        fake_grant_application['has_exported_before'] = True
        mocks[0].return_value = fake_grant_application
        mocks[1].return_value = fake_grant_application

        self.gal.has_viewed_review_page = True
        self.gal.save()

        response = self.client.post(self.url,
                                    data={
                                        'has_exported_before': True,
                                    })
        self.assertRedirects(response,
                             reverse('grant-applications:export-details',
                                     args=(self.gal.pk, )),
                             fetch_redirect_response=False)