def test_assigning_non_ist_project_manager_doesnt_end_spi2(spi_report): """Test that non IST project manager wont end SPI 2.""" investment_project = InvestmentProjectFactory() investment_project.project_manager = AdviserFactory() investment_project.project_manager_first_assigned_on = now() investment_project.project_manager_first_assigned_by = AdviserFactory() investment_project.save() rows = list(spi_report.rows()) assert len(rows) == 1 assert 'Project manager assigned' not in rows[0] assert 'Project manager assigned by' not in rows[0]
def test_assigning_ist_project_manager_ends_spi2(spi_report, ist_adviser): """Test if assigning IST project manager would end SPI 2.""" investment_project = InvestmentProjectFactory() investment_project.project_manager = ist_adviser adviser = AdviserFactory() investment_project.project_manager_first_assigned_on = now() investment_project.project_manager_first_assigned_by = adviser investment_project.save() rows = list(spi_report.rows()) assert len(rows) == 1 assigned_on = investment_project.project_manager_first_assigned_on assert rows[0]['Project manager assigned'] == assigned_on.isoformat() assert rows[0]['Project manager assigned by'] == adviser
def test_incomplete_fields_syncs_when_project_changes(opensearch_with_signals): """ When project fields change, the incomplete fields should update accordingly. """ project = InvestmentProjectFactory( stage_id=InvestmentProjectStage.won.value.id) adviser = AdviserFactory() opensearch_with_signals.indices.refresh() result = search_investment_project_by_id(project.pk) assert result.hits.total.value == 1 assert result.hits[0]['incomplete_fields'] == [ 'client_cannot_provide_total_investment', 'number_new_jobs', 'strategic_drivers', 'client_requirements', 'client_considering_other_countries', 'project_manager', 'project_assurance_adviser', 'client_cannot_provide_foreign_investment', 'government_assistance', 'number_safeguarded_jobs', 'r_and_d_budget', 'non_fdi_r_and_d_budget', 'new_tech_to_uk', 'export_revenue', 'address_1', 'address_town', 'address_postcode', 'actual_uk_regions', 'delivery_partners', 'actual_land_date', 'total_investment', 'uk_region_locations', 'foreign_equity_investment', ] project.client_cannot_provide_total_investment = False project.number_new_jobs = 3 project.client_requirements = 'things' project.client_considering_other_countries = True project.project_manager = adviser project.project_assurance_adviser = adviser project.client_cannot_provide_foreign_investment = True project.government_assistance = True project.number_safeguarded_jobs = 10 project.r_and_d_budget = True project.non_fdi_r_and_d_budget = True project.new_tech_to_uk = True project.export_revenue = True project.address_1 = 'Downing Street' project.address_town = 'London' project.address_postcode = 'SW1A 2AA' project.actual_land_date = date(2020, 1, 1) project.total_investment = Decimal('100.00') project.foreign_equity_investment = Decimal('50.00') project.save() opensearch_with_signals.indices.refresh() result = search_investment_project_by_id(project.pk) assert result.hits[0]['incomplete_fields'] == [ 'strategic_drivers', 'actual_uk_regions', 'delivery_partners', 'competitor_countries', 'uk_region_locations', 'average_salary', 'associated_non_fdi_r_and_d_project', ]