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

Admin for universal update script #4663

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

johniak
Copy link
Contributor

@johniak johniak commented Feb 28, 2025

AB#237765
This pull request introduces significant changes to the universal_update_script functionality, including new models, admin configurations, and Celery tasks. The most important changes include the addition of the UniversalUpdate model, the creation of admin forms and views for managing universal updates, and the implementation of Celery tasks for handling update processes.

Universal Update Script Enhancements:

Other Changes:

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 95.98811% with 27 lines in your changes missing coverage. Please review.

Project coverage is 86.02%. Comparing base (de4c545) to head (173fb68).

Files with missing lines Patch % Lines
.../hct_mis_api/apps/universal_update_script/admin.py 87.50% 11 Missing ⚠️
...ate_service/universal_individual_update_service.py 96.72% 10 Missing ⚠️
...ndividual_update_service/validator_and_handlers.py 96.66% 3 Missing ⚠️
..._individual_update_service/all_updatable_fields.py 93.93% 2 Missing ⚠️
...ndividual_update_service/create_backup_snapshot.py 98.18% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #4663      +/-   ##
===========================================
+ Coverage    84.32%   86.02%   +1.70%     
===========================================
  Files          547      556       +9     
  Lines        35996    36668     +672     
===========================================
+ Hits         30352    31542    +1190     
+ Misses        5644     5126     -518     
Flag Coverage Δ
e2e 60.36% <31.50%> (?)
unittests 84.53% <95.98%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if value is None and self.allow_multiple_selected:
return []
elif self.allow_multiple_selected:
processed_value = [v for v in value.split(",")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just value.split(",")

elif self.allow_multiple_selected:
processed_value = [v for v in value.split(",")]

if not isinstance(value, (tuple, list)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then value typing is incorrect

Comment on lines +46 to +54
db_count = Individual.objects.filter(unicef_id__in=unicef_ids, program_id=program_id).count()
if db_count != len(unicef_ids):
unicef_ids_from_db = list( # pragma: no cover
Individual.objects.filter(unicef_id__in=unicef_ids, program_id=program_id).values_list(
"unicef_id", flat=True
)
)
diff = set(unicef_ids) - set(unicef_ids_from_db) # pragma: no cover
raise Exception("Some unicef ids are not in the program: " + str(diff)) # pragma: no cover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a lot of pragmas, this case could be tested :D

Comment on lines +133 to +160
if self.individual_flex_fields is None:
return [] # pragma: no cover
for field, (name, validator, _handler) in self.individual_flex_fields.items():
value = row[headers.index(field)]
error = validator(value, name, row, self.business_area, self.program)
if error: # pragma: no cover
errors.append(f"Row: {row_index} - {error}")
return errors

def validate_household_flex_fields(
self, row: Tuple[Any, ...], headers: List[str], individual: Individual, row_index: int
) -> List[str]:
errors = []
if self.household_flex_fields is None:
return [] # pragma: no cover
for field, (name, validator, _handler) in self.household_flex_fields.items():
value = row[headers.index(field)]
error = validator(value, name, row, self.business_area, self.program)
if error: # pragma: no cover
errors.append(f"Row: {row_index} - {error}")
return errors

def validate_documents(
self, row: Tuple[Any, ...], headers: List[str], individual: Individual, row_index: int
) -> List[str]:
if self.document_fields is None:
return [] # pragma: no cover
errors = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the validations also could be tested not to spam with the pragmas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants