Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require uk recipient company before project can move to verify win stage #5461

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions datahub/investment/project/test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ContactFactory,
)
from datahub.core.constants import (
Country,
InvestmentBusinessActivity,
InvestmentProjectStage,
InvestmentStrategicDriver,
Expand Down Expand Up @@ -169,6 +170,10 @@ class VerifyWinInvestmentProjectFactory(ActiveInvestmentProjectFactory):
address_postcode = factory.Faker('postcode')
average_salary_id = SalaryRange.below_25000.value.id
specific_programme_id = SpecificProgramme.space.value.id
uk_company = factory.SubFactory(
CompanyFactory,
address_country_id=Country.united_kingdom.value.id,
)

@to_many_field
def actual_uk_regions(self):
Expand Down
4 changes: 3 additions & 1 deletion datahub/investment/project/test/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from datahub.company.test.factories import AdviserFactory, ContactFactory
from datahub.company.test.factories import AdviserFactory, CompanyFactory, ContactFactory
from datahub.core import constants
from datahub.core.test_utils import random_obj_for_model
from datahub.investment.project.constants import SpecificProgramme
Expand Down Expand Up @@ -293,6 +293,7 @@ def test_validate_verify_win_instance_failure():
'foreign_equity_investment': 'This field is required.',
'actual_land_date': 'This field is required.',
'specific_programme': 'This field is required.',
'uk_company': 'This field is required.',
}


Expand Down Expand Up @@ -359,6 +360,7 @@ def test_validate_verify_win_instance_with_cond_fields():
average_salary_id=constants.SalaryRange.below_25000.value.id,
actual_land_date=date.today(),
specific_programme_id=SpecificProgramme.space.value.id,
uk_company=CompanyFactory(address_country_id=constants.Country.united_kingdom.value.id),
)
errors = validate(instance=project)
assert not errors
Expand Down
4 changes: 4 additions & 0 deletions datahub/investment/project/test/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@ def test_change_stage_verify_win_failure(self):
'foreign_equity_investment': ['This field is required.'],
'actual_land_date': ['This field is required.'],
'specific_programme': ['This field is required.'],
'uk_company': ['This field is required.'],
}

@pytest.mark.parametrize(
Expand Down Expand Up @@ -1556,6 +1557,9 @@ def test_change_stage_verify_win_success(self, field):
average_salary_id=constants.SalaryRange.below_25000.value.id,
actual_land_date=factory.Faker('past_date'),
specific_programme_id=SpecificProgramme.space.value.id,
uk_company=CompanyFactory(
address_country_id=constants.Country.united_kingdom.value.id,
),
**extra,
)
url = reverse('api-v3:investment:investment-item', kwargs={'pk': project.pk})
Expand Down
1 change: 1 addition & 0 deletions datahub/investment/project/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_required_fields_after_stage(cls):
'delivery_partners': Stage.verify_win.value,
'actual_land_date': Stage.verify_win.value,
'specific_programme': Stage.verify_win.value,
'uk_company': Stage.verify_win.value,
}

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions datahub/search/investment/test/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def test_incomplete_fields_syncs_when_project_changes(opensearch_with_signals):
'delivery_partners',
'actual_land_date',
'specific_programme',
'uk_company',
'total_investment',
'uk_region_locations',
'foreign_equity_investment',
Expand Down Expand Up @@ -407,6 +408,7 @@ def test_incomplete_fields_syncs_when_project_changes(opensearch_with_signals):
'actual_uk_regions',
'delivery_partners',
'specific_programme',
'uk_company',
'competitor_countries',
'uk_region_locations',
'average_salary',
Expand Down
Loading