Skip to content

Commit

Permalink
Merge branch 'develop' into rdi-import-validation-messages-universal-…
Browse files Browse the repository at this point in the history
…formatting
  • Loading branch information
pkujawa authored Aug 30, 2024
2 parents 13d4af1 + 2e7b5de commit c7572bc
Show file tree
Hide file tree
Showing 16 changed files with 542 additions and 379 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ jobs:

- name: E2E tests
run: |
exit 0 # TODO: remove this line when the e2e tests are working again
compose_file=./deployment/docker-compose.selenium-night.yml
if [ "${{ github.event_name }}" = "pull_request" ]; then
compose_file=./deployment/docker-compose.selenium.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class UserPartnerTest(TestCase):
def setUpTestData(cls) -> None:
cls.role_1 = Role.objects.create(name="Create_program", permissions=["PROGRAMME_CREATE"])
cls.role_2 = Role.objects.create(name="Finish_program", permissions=["PROGRAMME_FINISH"])
cls.area_1 = AreaFactory(name="Area 1")
cls.area_2 = AreaFactory(name="Area 2")
cls.area_1 = AreaFactory(name="Area 1", p_code="AREA1")
cls.area_2 = AreaFactory(name="Area 2", p_code="AREA2")
create_afghanistan()
cls.business_area = BusinessArea.objects.get(slug="afghanistan")
cls.program = ProgramFactory.create(status=Program.DRAFT, business_area=cls.business_area)
Expand Down
10 changes: 6 additions & 4 deletions backend/hct_mis_api/apps/geo/tests/test_signal_create_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def setUpTestData(cls) -> None:
)
cls.area_type_other = AreaTypeFactory(name="Area Type Other", country=country_other)

cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=cls.area_type_afg)
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=cls.area_type_afg)
cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=cls.area_type_afg, p_code="AREA-IN-AFG1")
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=cls.area_type_afg, p_code="AREA-IN-AFG2")

cls.program = ProgramFactory.create(
status=Program.DRAFT, business_area=cls.business_area, partner_access=Program.SELECTED_PARTNERS_ACCESS
Expand Down Expand Up @@ -64,8 +64,10 @@ def test_add_new_area_to_full_access(self) -> None:

self.assertEqual(self.program_other_unicef_through.areas.count(), 2)

self.new_area_in_afg = AreaFactory(name="Area in AFG", area_type=self.area_type_afg)
self.new_area_not_in_afg = AreaFactory(name="Area not in AFG", area_type=self.area_type_other)
self.new_area_in_afg = AreaFactory(name="Area in AFG", area_type=self.area_type_afg, p_code="AREA-IN-AFG")
self.new_area_not_in_afg = AreaFactory(
name="Area not in AFG", area_type=self.area_type_other, p_code="AREA-NOT-IN-AFG"
)

self.assertEqual(self.program_partner_through.areas.count(), 2)
self.assertEqual(self.program_unicef_through.areas.count(), 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def setUpTestData(cls) -> None:
role = RoleFactory(name="GRIEVANCES CROSS AREA FILTER", permissions=["GRIEVANCES_CROSS_AREA_FILTER"])
UserRole.objects.create(business_area=cls.business_area, user=cls.user, role=role)

cls.admin_area1 = AreaFactory(name="Admin Area 1", level=2)
cls.admin_area2 = AreaFactory(name="Admin Area 2", level=2)
cls.admin_area1 = AreaFactory(name="Admin Area 1", level=2, p_code="AREA1")
cls.admin_area2 = AreaFactory(name="Admin Area 2", level=2, p_code="AREA2")

cls.program = ProgramFactory(business_area=cls.business_area, status=Program.ACTIVE)

Expand Down
12 changes: 7 additions & 5 deletions backend/hct_mis_api/apps/program/tests/test_copy_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ def setUpTestData(cls) -> None:
)
cls.area_type_other = AreaTypeFactory(name="Area Type Other", country=country_other)

cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg)
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg)
cls.area_not_in_afg = AreaFactory(name="Area not in AFG", area_type=cls.area_type_other)
cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg, p_code="AREA-IN-AFG1")
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg, p_code="AREA-IN-AFG2")
cls.area_not_in_afg = AreaFactory(
name="Area not in AFG", area_type=cls.area_type_other, p_code="AREA-NOT-IN-AFG"
)

# PDU data - on original Program - SHOULD NOT BE COPIED into new Program
pdu_data = PeriodicFieldDataFactory(
Expand Down Expand Up @@ -408,8 +410,8 @@ def test_copy_program_with_existing_name(self) -> None:
)
def test_copy_program_with_partners(self, _: Any, partner_access: str) -> None:
self.create_user_role_with_permissions(self.user, [Permissions.PROGRAMME_DUPLICATE], self.business_area)
area1 = AreaFactory(name="North Brianmouth", area_type=self.area_type_other)
area2 = AreaFactory(name="South Catherine", area_type=self.area_type_other)
area1 = AreaFactory(name="North Brianmouth", area_type=self.area_type_other, p_code="NORTH-B")
area2 = AreaFactory(name="South Catherine", area_type=self.area_type_other, p_code="SOUTH-C")
partner2 = PartnerFactory(name="New Partner")
self.copy_data["programData"]["partners"] = [
{
Expand Down
12 changes: 7 additions & 5 deletions backend/hct_mis_api/apps/program/tests/test_create_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ def setUpTestData(cls) -> None:
)
cls.area_type_other = AreaTypeFactory(name="Area Type Other", country=country_other)

cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg)
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg)
cls.area_not_in_afg = AreaFactory(name="Area not in AFG", area_type=cls.area_type_other)
cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg, p_code="AREA-IN-AFG1")
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg, p_code="AREA-IN-AFG2")
cls.area_not_in_afg = AreaFactory(
name="Area not in AFG", area_type=cls.area_type_other, p_code="AREA-NOT-IN-AFG"
)

def test_create_program_not_authenticated(self) -> None:
self.snapshot_graphql_request(request_string=self.CREATE_PROGRAM_MUTATION, variables=self.program_data)
Expand Down Expand Up @@ -261,8 +263,8 @@ def test_create_program_with_programme_code(self) -> None:
)
def test_create_program_with_partners(self, _: Any, partner_access: str) -> None:
self.create_user_role_with_permissions(self.user, [Permissions.PROGRAMME_CREATE], self.business_area)
area1 = AreaFactory(name="North Brianmouth", area_type=self.area_type_other)
area2 = AreaFactory(name="South Catherine", area_type=self.area_type_other)
area1 = AreaFactory(name="North Brianmouth", area_type=self.area_type_other, p_code="NORTH-B")
area2 = AreaFactory(name="South Catherine", area_type=self.area_type_other, p_code="SOUTH-C")
partner2 = PartnerFactory(name="New Partner")
self.program_data["programData"]["partners"] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def setUpTestData(cls) -> None:
)
cls.area_type_other = AreaTypeFactory(name="Area Type Other", country=country_other)

cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg)
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg)
cls.area_not_in_afg = AreaFactory(name="Area not in AFG", area_type=cls.area_type_other)
cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg, p_code="AREA-IN-AFG1")
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg, p_code="AREA-IN-AFG2")
cls.area_not_in_afg = AreaFactory(
name="Area not in AFG", area_type=cls.area_type_other, p_code="AREA-NOT-IN-AFG"
)

cls.program = ProgramFactory.create(
status=Program.DRAFT, business_area=cls.business_area, partner_access=Program.NONE_PARTNERS_ACCESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def setUpTestData(cls) -> None:
)
cls.area_type_other = AreaTypeFactory(name="Area Type Other", country=country_other)

cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg)
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg)
cls.area_not_in_afg = AreaFactory(name="Area not in AFG", area_type=cls.area_type_other)
cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg, p_code="AREA-IN-AFG1")
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg, p_code="AREA-IN-AFG2")
cls.area_not_in_afg = AreaFactory(
name="Area not in AFG", area_type=cls.area_type_other, p_code="AREA-NOT-IN-AFG"
)

cls.program = ProgramFactory.create(
status=Program.DRAFT, business_area=cls.business_area, partner_access=Program.SELECTED_PARTNERS_ACCESS
Expand Down
24 changes: 15 additions & 9 deletions backend/hct_mis_api/apps/program/tests/test_update_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ def setUpTestData(cls) -> None:
)
cls.area_type_other = AreaTypeFactory(name="Area Type Other", country=country_other)

cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg)
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg)
cls.area_not_in_afg = AreaFactory(name="Area not in AFG", area_type=cls.area_type_other)
cls.area_in_afg_1 = AreaFactory(name="Area in AFG 1", area_type=area_type_afg, p_code="AREA-IN-AFG1")
cls.area_in_afg_2 = AreaFactory(name="Area in AFG 2", area_type=area_type_afg, p_code="AREA-IN-AFG2")
cls.area_not_in_afg = AreaFactory(
name="Area not in AFG", area_type=cls.area_type_other, p_code="AREA-NOT-IN-AFG2"
)

unicef_program.areas.set([cls.area_in_afg_1, cls.area_in_afg_2])

Expand Down Expand Up @@ -229,9 +231,11 @@ def test_update_program_authenticated(
]
)
def test_update_program_partners(self, _: Any, partner_access: str) -> None:
area1 = AreaFactory(name="Area1", area_type=self.area_type_other)
area2 = AreaFactory(name="Area2", area_type=self.area_type_other)
area_to_be_unselected = AreaFactory(name="AreaToBeUnselected", area_type=self.area_type_other)
area1 = AreaFactory(name="Area1", area_type=self.area_type_other, p_code="AREA1")
area2 = AreaFactory(name="Area2", area_type=self.area_type_other, p_code="AREA2")
area_to_be_unselected = AreaFactory(
name="AreaToBeUnselected", area_type=self.area_type_other, p_code="AREA-TO-BE-UNSELECTED"
)
program_partner = ProgramPartnerThrough.objects.create(
program=self.program,
partner=self.partner,
Expand Down Expand Up @@ -274,9 +278,11 @@ def test_update_program_partners(self, _: Any, partner_access: str) -> None:
)

def test_update_program_partners_invalid_access_type_from_object(self) -> None:
area1 = AreaFactory(name="Area1", area_type=self.area_type_other)
area2 = AreaFactory(name="Area2", area_type=self.area_type_other)
area_to_be_unselected = AreaFactory(name="AreaToBeUnselected", area_type=self.area_type_other)
area1 = AreaFactory(name="Area1", area_type=self.area_type_other, p_code="AREA1")
area2 = AreaFactory(name="Area2", area_type=self.area_type_other, p_code="AREA2")
area_to_be_unselected = AreaFactory(
name="AreaToBeUnselected", area_type=self.area_type_other, p_code="AREA-TO-BE-UNSELECTED"
)
program_partner = ProgramPartnerThrough.objects.create(
program=self.program,
partner=self.partner,
Expand Down
3 changes: 3 additions & 0 deletions backend/hct_mis_api/apps/targeting/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ def copy_target_criteria(cls, targeting_criteria: TargetingCriteria) -> Targetin
ind_filter.pk = None
ind_filter.individuals_filters_block = ind_filter_block_copy
ind_filter.save()
targeting_criteria_copy.household_ids = targeting_criteria.household_ids
targeting_criteria_copy.individual_ids = targeting_criteria.individual_ids
targeting_criteria_copy.save()

return targeting_criteria_copy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
'name': 'Test New Copy Name',
'status': 'OPEN',
'targetingCriteria': {
'householdIds': '',
'individualIds': '',
'rules': [
{
'filters': [
Expand Down Expand Up @@ -89,3 +91,81 @@
}
]
}

snapshots['TestCopyTargetPopulationMutation::test_copy_with_household_ids_0_with_permission 1'] = {
'data': {
'copyTargetPopulation': {
'targetPopulation': {
'name': 'Test New Copy Name',
'status': 'OPEN',
'targetingCriteria': {
'householdIds': "['HH-1']",
'individualIds': '',
'rules': [
]
},
'totalHouseholdsCount': None,
'totalIndividualsCount': None
}
}
}
}

snapshots['TestCopyTargetPopulationMutation::test_copy_with_household_ids_1_without_permission 1'] = {
'data': {
'copyTargetPopulation': None
},
'errors': [
{
'locations': [
{
'column': 15,
'line': 3
}
],
'message': 'Permission Denied: User does not have correct permission.',
'path': [
'copyTargetPopulation'
]
}
]
}

snapshots['TestCopyTargetPopulationMutation::test_copy_with_individual_ids_0_with_permission 1'] = {
'data': {
'copyTargetPopulation': {
'targetPopulation': {
'name': 'Test New Copy Name',
'status': 'OPEN',
'targetingCriteria': {
'householdIds': '',
'individualIds': "['IND-1']",
'rules': [
]
},
'totalHouseholdsCount': None,
'totalIndividualsCount': None
}
}
}
}

snapshots['TestCopyTargetPopulationMutation::test_copy_with_individual_ids_1_without_permission 1'] = {
'data': {
'copyTargetPopulation': None
},
'errors': [
{
'locations': [
{
'column': 15,
'line': 3
}
],
'message': 'Permission Denied: User does not have correct permission.',
'path': [
'copyTargetPopulation'
]
}
]
}
Loading

0 comments on commit c7572bc

Please sign in to comment.