Exemple #1
0
 def test_grant_application_pdf_download(self, *mocks):
     ga = CompletedGrantApplicationFactory()
     ga.send_for_review()
     path = reverse('grant-applications:grant-applications-pdf', args=(ga.id,))
     response = self.client.get(path)
     self.assertEqual(response.status_code, HTTP_200_OK)
     self.assertEquals(
         response['Content-Disposition'],
         'attachment; filename="grant-application.pdf"'
     )
Exemple #2
0
class TestGrantManagementSupportingInformation(BaseTestCase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.notify_service_patch = patch(
            'web.grant_management.flows.NotifyService')
        cls.notify_service_patch.start()

    @classmethod
    def tearDownClass(cls):
        super().tearDownClass()
        cls.notify_service_patch.stop()

    def setUp(self):
        super().setUp()
        self.ga = CompletedGrantApplicationFactory(
            company__dnb_get_company_responses=None)
        self.ga.send_for_review()
        self.si_content = SupportingInformationContent(self.ga)

    @patch.object(DnbServiceClient,
                  'get_company',
                  side_effect=DnbServiceClientException)
    def test_business_entity_content_on_dnb_service_error(self, *mocks):
        self.assertIsNone(self.si_content.verify_business_entity_content)

    @patch.object(DnbServiceClient,
                  'get_company',
                  return_value={
                      'primary_name': 'company-1',
                      'is_employees_number_estimated': True,
                      'employee_number': 1,
                      'annual_sales': None,
                      'annual_sales_currency': None
                  })
    def test_business_entity_content_if_annual_sales_is_none(self, *mocks):
        self.assertEqual(
            self.si_content.verify_business_entity_content['annual_sales'], 0)

    @patch.object(DnbServiceClient,
                  'get_company',
                  return_value={'primary_name': 'company-1'})
    def test_dnb_company_data_from_db_cache_instead_of_dnb_service(
            self, *mocks):
        DnbGetCompanyResponseFactory(company=self.ga.company,
                                     dnb_data={'response': 1})
        DnbGetCompanyResponseFactory(company=self.ga.company,
                                     dnb_data={'response': 2})
        self.assertIsNotNone(self.si_content.dnb_company_data)
        self.assertEqual(self.si_content.dnb_company_data['response'], 2)
Exemple #3
0
 def test_update_grant_application(self, *mocks):
     event = EventFactory()
     ga = CompletedGrantApplicationFactory()
     path = reverse('grant-applications:grant-applications-detail', args=(ga.id,))
     response = self.client.patch(path, {'event': event.id})
     self.assertEqual(response.status_code, HTTP_200_OK, msg=response.data)
     self.assert_response_data_contains(response, data_contains={'event': event.id})
Exemple #4
0
 def test_grant_application_send_for_review(self, *mocks):
     ga = CompletedGrantApplicationFactory(application_summary=[])
     path = reverse('grant-applications:grant-applications-send-for-review', args=(ga.id,))
     response = self.client.post(path, data={'application_summary': 'A summary'})
     self.assertEqual(response.status_code, HTTP_200_OK)
     self.assertIsNotNone(response.data['grant_management_process'])
     self.assertTrue(GrantManagementProcess.objects.filter(grant_application=ga).exists())
     self.assertEqual(response.data['application_summary'], 'A summary')
Exemple #5
0
 def test_list_grant_applications(self, *mocks):
     gas = CompletedGrantApplicationFactory.create_batch(size=3)
     path = reverse('grant-applications:grant-applications-list')
     response = self.client.get(path=path)
     self.assertEqual(response.status_code, HTTP_200_OK, msg=response.data)
     self.assert_response_data_contains(
         response,
         data_contains=[
             {'id': gas[0].id_str},
             {'id': gas[1].id_str},
             {'id': gas[2].id_str}
         ]
     )
 def setUp(self):
     super().setUp()
     self.user = UserFactory(is_superuser=True)
     self.ga = CompletedGrantApplicationFactory()
Exemple #7
0
 def setUp(self):
     super().setUp()
     self.ga = CompletedGrantApplicationFactory(
         company__dnb_get_company_responses=None)
     self.ga.send_for_review()
     self.si_content = SupportingInformationContent(self.ga)
Exemple #8
0
 def setUp(self):
     super().setUp()
     self.ga = CompletedGrantApplicationFactory(stateaid_set=None)
Exemple #9
0
 def test_get_grant_application_detail(self, *mocks):
     ga = CompletedGrantApplicationFactory()
     path = reverse('grant-applications:grant-applications-detail', args=(ga.id,))
     response = self.client.get(path)
     self.assertEqual(response.status_code, HTTP_200_OK, msg=response.data)
     self.assert_response_data_contains(
         response,
         data_contains={
             'id': ga.id_str,
             'is_eligible': ga.is_eligible,
             'previous_applications': ga.previous_applications,
             'event': {
                 'id': ga.event.id_str,
                 'city': ga.event.city,
                 'country': ga.event.country,
                 'name': ga.event.name,
                 'show_type': ga.event.show_type,
                 'start_date': str(ga.event.start_date),
                 'end_date': str(ga.event.end_date),
                 'sector': ga.event.sector,
                 'sub_sector': ga.event.sub_sector,
                 'tcp': ga.event.tcp,
                 'tcp_website': ga.event.tcp_website,
             },
             'is_already_committed_to_event': ga.is_already_committed_to_event,
             'search_term': ga.search_term,
             'company': {
                 'id': ga.company.id_str,
                 'duns_number': ga.company.duns_number,
                 'registration_number': ga.company.registration_number,
                 'name': ga.company.name,
                 'last_dnb_get_company_response': {
                     'id': ga.company.last_dnb_get_company_response.id_str,
                     'dnb_data': ga.company.last_dnb_get_company_response.dnb_data,
                     'company_address': ga.company.last_dnb_get_company_response.company_address,
                     'registration_number':
                         ga.company.last_dnb_get_company_response.registration_number
                 },
                 'previous_applications': 0,
                 'applications_in_review': 0,
             },
             'manual_company_type': ga.manual_company_type,
             'manual_company_name': ga.manual_company_name,
             'manual_company_address_line_1': ga.manual_company_address_line_1,
             'manual_company_address_line_2': ga.manual_company_address_line_2,
             'manual_company_address_town': ga.manual_company_address_town,
             'manual_company_address_county': ga.manual_company_address_county,
             'manual_company_address_postcode': ga.manual_company_address_postcode,
             'manual_time_trading_in_uk': ga.manual_time_trading_in_uk,
             'manual_registration_number': ga.manual_registration_number,
             'manual_vat_number': ga.manual_vat_number,
             'manual_website': ga.manual_website,
             'number_of_employees': ga.number_of_employees,
             'is_turnover_greater_than': ga.is_turnover_greater_than,
             'applicant_full_name': ga.applicant_full_name,
             'applicant_email': ga.applicant_email,
             'applicant_mobile_number': ga.applicant_mobile_number,
             'job_title': ga.job_title,
             'previous_years_turnover_1': str(ga.previous_years_turnover_1),
             'previous_years_turnover_2': str(ga.previous_years_turnover_2),
             'previous_years_turnover_3': str(ga.previous_years_turnover_3),
             'previous_years_export_turnover_1': str(ga.previous_years_export_turnover_1),
             'previous_years_export_turnover_2': str(ga.previous_years_export_turnover_2),
             'previous_years_export_turnover_3': str(ga.previous_years_export_turnover_3),
             'sector': {
                 'id': ga.sector.id_str,
                 'full_name': ga.sector.full_name,
             },
             'other_business_names': ga.other_business_names,
             'products_and_services_description': ga.products_and_services_description,
             'products_and_services_competitors': ga.products_and_services_competitors,
             'has_exported_before': ga.has_exported_before,
             'has_product_or_service_for_export': ga.has_product_or_service_for_export,
             'has_exported_in_last_12_months': ga.has_exported_in_last_12_months,
             'export_regions': ga.export_regions,
             'markets_intending_on_exporting_to': ga.markets_intending_on_exporting_to,
             'is_in_contact_with_dit_trade_advisor': ga.is_in_contact_with_dit_trade_advisor,
             'ita_name': ga.ita_name,
             'ita_email': ga.ita_email,
             'ita_mobile_number': ga.ita_mobile_number,
             'export_experience_description': ga.export_experience_description,
             'export_strategy': ga.export_strategy,
             'interest_in_event_description': ga.interest_in_event_description,
             'is_in_contact_with_tcp': ga.is_in_contact_with_tcp,
             'tcp_name': ga.tcp_name,
             'tcp_email': ga.tcp_email,
             'tcp_mobile_number': ga.tcp_mobile_number,
             'is_intending_to_exhibit_as_tcp_stand': ga.is_intending_to_exhibit_as_tcp_stand,
             'stand_trade_name': ga.stand_trade_name,
             'trade_show_experience_description': ga.trade_show_experience_description,
             'additional_guidance': ga.additional_guidance,
             'application_summary': ga.application_summary,
             'sent_for_review': ga.sent_for_review,
         }
     )
Exemple #10
0
 def test_grant_application_send_for_review_requires_application_summary(self, *mocks):
     ga = CompletedGrantApplicationFactory()
     path = reverse('grant-applications:grant-applications-send-for-review', args=(ga.id,))
     response = self.client.post(path)
     self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)
     self.assertEqual(response.data['application_summary'][0].code, 'required')