Ejemplo n.º 1
0
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]
Ejemplo n.º 2
0
def test_investment_project_auto_updates_to_es(es_with_signals):
    """Tests if investment project gets synced to Elasticsearch."""
    project = InvestmentProjectFactory()
    new_test_name = 'even_harder_to_find_investment_project'
    project.name = new_test_name
    project.save()
    es_with_signals.indices.refresh()

    result = get_search_by_entity_query(
        InvestmentProject,
        term='',
        filter_data={'name': new_test_name},
    ).execute()

    assert result.hits.total == 1
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def test_investment_project_auto_updates_to_opensearch(
        opensearch_with_signals):
    """Tests if investment project gets synced to OpenSearch."""
    project = InvestmentProjectFactory()
    new_test_name = 'even_harder_to_find_investment_project'
    project.name = new_test_name
    project.save()
    opensearch_with_signals.indices.refresh()

    result = get_search_by_entities_query(
        [InvestmentProject],
        term='',
        filter_data={
            'name': new_test_name
        },
    ).execute()

    assert result.hits.total.value == 1
Ejemplo n.º 5
0
def test_creates_stage_log_if_stage_was_modified():
    """Tests that change to investment project stage creates a stage log record."""
    dates = (
        datetime(2017, 4, 28, 17, 35, tzinfo=utc),
        datetime(2017, 4, 28, 17, 37, tzinfo=utc),
    )
    date_iter = iter(dates)

    with freeze_time(next(date_iter)):
        project = InvestmentProjectFactory()
    with freeze_time(next(date_iter)):
        project.stage_id = constants.InvestmentProjectStage.assign_pm.value.id
        project.save()

    date_iter = iter(dates)
    assert [(entry.stage.id, entry.created_on)
            for entry in project.stage_log.order_by('created_on')] == [
                (UUID(constants.InvestmentProjectStage.prospect.value.id),
                 next(date_iter)),
                (UUID(constants.InvestmentProjectStage.assign_pm.value.id),
                 next(date_iter)),
            ]
Ejemplo n.º 6
0
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',
    ]
Ejemplo n.º 7
0
def test_doesnt_create_stage_log_if_stage_was_not_modified():
    """Tests that stage log is not created when there is no change to stage."""
    project = InvestmentProjectFactory()
    # no change to the stage
    project.save()
    assert project.stage_log.count() == 1