-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3853 from unicef/develop
Staging with peoples enh
- Loading branch information
Showing
328 changed files
with
20,083 additions
and
691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 141 additions & 72 deletions
213
backend/hct_mis_api/apps/core/attributes_qet_queries.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
334 changes: 334 additions & 0 deletions
334
backend/hct_mis_api/apps/core/tests/test_attributes_get_queries.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,89 @@ | ||
from unittest.mock import patch | ||
|
||
from hct_mis_api.apps.core.base_test_case import APITestCase | ||
from hct_mis_api.apps.core.field_attributes.core_fields_attributes import ( | ||
CORE_FIELDS_ATTRIBUTES, | ||
FieldFactory, | ||
) | ||
from hct_mis_api.apps.core.field_attributes.fields_types import TYPE_STRING, Scope | ||
|
||
|
||
class TestCoreFields(APITestCase): | ||
|
||
def setUp(self) -> None: | ||
self.scopes = [Scope.GLOBAL, Scope.XLSX_PEOPLE] | ||
super().setUp() | ||
|
||
def test_all_fields_have_lookup(self) -> None: | ||
for field in CORE_FIELDS_ATTRIBUTES: | ||
self.assertTrue(field.get("lookup"), f'{field.get("name")} does not have a lookup') | ||
|
||
@patch( | ||
"hct_mis_api.apps.core.field_attributes.core_fields_attributes.CORE_FIELDS_ATTRIBUTES", | ||
[ | ||
{ | ||
"id": "b1f90314-b8b8-4bcb-9265-9d48d1fce5a4", | ||
"type": TYPE_STRING, | ||
"name": "given_name", | ||
"lookup": "given_name", | ||
"required": False, | ||
"label": {"English(EN)": "Given name"}, | ||
"hint": "", | ||
"choices": [], | ||
"associated_with": "individual", | ||
"xlsx_field": "given_name_i_c", | ||
"scope": [Scope.GLOBAL, Scope.TARGETING, Scope.KOBO_IMPORT, Scope.INDIVIDUAL_UPDATE, Scope.XLSX_PEOPLE], | ||
}, | ||
{ | ||
"id": "b1f90314-b8b8-4bcb-9265-9d48d1fce524", | ||
"type": TYPE_STRING, | ||
"name": "given_name1", | ||
"lookup": "given_name1", | ||
"required": False, | ||
"label": {"English(EN)": "Given name1"}, | ||
"hint": "", | ||
"choices": [], | ||
"associated_with": "individual", | ||
"xlsx_field": "given_name1_i_c", | ||
"scope": [Scope.GLOBAL, Scope.TARGETING, Scope.KOBO_IMPORT, Scope.INDIVIDUAL_UPDATE], | ||
}, | ||
{ | ||
"id": "36ab3421-6e7a-40d1-b816-ea5cbdcc0b6a", | ||
"type": TYPE_STRING, | ||
"name": "full_name", | ||
"lookup": "full_name", | ||
"required": True, | ||
"label": {"English(EN)": "Full name"}, | ||
"hint": "", | ||
"choices": [], | ||
"associated_with": "individual", | ||
"xlsx_field": "full_name_i_c", | ||
"scope": [Scope.GLOBAL, Scope.XLSX_PEOPLE], | ||
}, | ||
], | ||
) | ||
def test_xlsx_people_scope_filtering(self) -> None: | ||
factory_result = FieldFactory.from_only_scopes(self.scopes) | ||
self.assertEqual(len(factory_result), 2) | ||
|
||
@patch( | ||
"hct_mis_api.apps.core.field_attributes.core_fields_attributes.CORE_FIELDS_ATTRIBUTES", | ||
[ | ||
{ | ||
"id": "b1f90314-b8b8-4bcb-9265-9d48d1fce5a4", | ||
"type": TYPE_STRING, | ||
"name": "given_name", | ||
"lookup": "given_name", | ||
"required": False, | ||
"label": {"English(EN)": "Given name"}, | ||
"hint": "", | ||
"choices": [], | ||
"associated_with": "individual", | ||
"xlsx_field": "given_name_i_c", | ||
"scope": [Scope.GLOBAL, Scope.TARGETING, Scope.KOBO_IMPORT, Scope.INDIVIDUAL_UPDATE, Scope.XLSX_PEOPLE], | ||
} | ||
], | ||
) | ||
def test_xlsx_people_scope_modification(self) -> None: | ||
factory_result = FieldFactory.from_only_scopes(self.scopes) | ||
self.assertEqual(factory_result[0]["xlsx_field"], "pp_given_name_i_c") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.