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() # saving separately so that project_manager_first_assigned_on is updated investment_project.project_manager = AdviserFactory() investment_project.save() rows = list(spi_report.rows()) assert len(rows) == 1 assert 'Project manager assigned' 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() # saving separately so that project_manager_first_assigned_on is updated investment_project.project_manager = ist_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()
def test_investment_project_auto_updates_to_es(setup_es): """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() setup_es.indices.refresh() result = get_search_by_entity_query( term='', filter_data={ 'name': new_test_name }, entity=InvestmentProject, ).execute() assert result.hits.total == 1
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)), ]
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