def test_no_gva_multiplier_for_financial_year_logs_if_later_multiplier_available( self, caplog, ): """ Test when a GVA Multiplier is not present for the financial year 2050 but one is present for 2052. Checks a log is added to the exception log to flag that data is missing for that year. """ caplog.set_level('WARNING') GVAMultiplierFactory( multiplier=Decimal('0.5'), financial_year=2052, fdi_sic_grouping_id=FDISICGroupingConstant.electric.value.id, ) GVAMultiplierFactory( multiplier=Decimal('0.5'), financial_year=2049, fdi_sic_grouping_id=FDISICGroupingConstant.electric.value.id, ) project = InvestmentProjectFactory( sector_id=SectorConstant.renewable_energy_wind.value.id, business_activities=[], investment_type_id=InvestmentTypeConstant.fdi.value.id, foreign_equity_investment=1000, actual_land_date=date(2050, 5, 1), ) assert project.gva_multiplier.financial_year == 2052 assert caplog.messages[0] == ( 'Unable to find a GVA Multiplier for financial year 2050' f' fdi sic grouping id {FDISICGroupingConstant.electric.value.id}')
def project_with_max_gross_value_added(): """Test fixture returns an investment project with the max gross value.""" gva_multiplier = GVAMultiplierFactory( multiplier=Decimal('9.999999'), financial_year=1980, ) with mock.patch( 'datahub.investment.project.gva_utils.GrossValueAddedCalculator._get_gva_multiplier', ) as mock_get_multiplier: mock_get_multiplier.return_value = gva_multiplier yield InvestmentProjectFactory( investment_type_id=constants.InvestmentType.fdi.value.id, name='won project', description='investmentproject3', estimated_land_date=datetime.date(2027, 9, 13), actual_land_date=datetime.date(2022, 11, 13), investor_company=CompanyFactory( address_country_id=constants.Country.united_kingdom.value.id, ), project_manager=AdviserFactory(), project_assurance_adviser=AdviserFactory(), fdi_value_id=constants.FDIValue.higher.value.id, status=InvestmentProject.Status.WON, uk_region_locations=[ constants.UKRegion.north_west.value.id, ], level_of_involvement_id=Involvement.hq_only.value.id, likelihood_to_land_id=None, foreign_equity_investment=9999999999999999999, )
def get_gva_multiplier(): """Get a GVA Multiplier for the year 3010""" yield GVAMultiplierFactory( financial_year=3010, fdi_sic_grouping_id=FDISICGrouping.retail.value.id, multiplier=2, )
def test_calculate_gva( self, foreign_equity_investment, multiplier_value, expected_gross_value_added, ): """Test calculate GVA.""" gva_multiplier = GVAMultiplierFactory( multiplier=multiplier_value, financial_year=1980, ) with mock.patch( 'datahub.investment.project.gva_utils.GrossValueAddedCalculator._get_gva_multiplier', ) as mock_get_multiplier: mock_get_multiplier.return_value = gva_multiplier project = InvestmentProjectFactory( foreign_equity_investment=foreign_equity_investment, investment_type_id=InvestmentTypeConstant.fdi.value.id, sector_id=SectorConstant.renewable_energy_wind.value.id, ) if not expected_gross_value_added: assert not project.gross_value_added else: assert project.gross_value_added == Decimal( expected_gross_value_added)
def test_no_gva_multiplier_for_financial_year_returns_latest_year(self): """ Test when a GVA Multiplier is not present for the financial year 2050. """ GVAMultiplierFactory( multiplier=Decimal('0.5'), financial_year=2040, fdi_sic_grouping_id=FDISICGroupingConstant.electric.value.id, ) project = InvestmentProjectFactory( sector_id=SectorConstant.renewable_energy_wind.value.id, business_activities=[], investment_type_id=InvestmentTypeConstant.fdi.value.id, foreign_equity_investment=1000, ) assert project.gva_multiplier.financial_year == 2040