Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Jan 17, 2025
1 parent ea11b98 commit 0f27aad
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 116 deletions.
12 changes: 6 additions & 6 deletions src/hct_mis_api/apps/grievance/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ def filter_queryset(self, queryset: QuerySet) -> QuerySet:
queryset.model.objects.none()
for name, value in cleaned_data.items():
queryset = self.filters[name].filter(queryset, value)
assert isinstance(queryset, models.QuerySet), (
"Expected '{}.{}' to return a QuerySet, but got a {} instead.".format(
type(self).__name__,
name,
type(queryset).__name__,
)
assert isinstance(
queryset, models.QuerySet
), "Expected '{}.{}' to return a QuerySet, but got a {} instead.".format(
type(self).__name__,
name,
type(queryset).__name__,
)

if payment_record_objects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def _logic(ba: BusinessArea) -> None:
logging.info(
f"Found ticket (id={ticket.id}) with disability: '{disability_value}'. Changing to '{new_disability_value}'"
)
ticket.individual_data_update_ticket_details.individual_data["disability"]["value"] = (
new_disability_value
)
ticket.individual_data_update_ticket_details.individual_data["disability"][
"value"
] = new_disability_value
ticket.individual_data_update_ticket_details.save()

if business_area:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,19 @@ def save(self) -> List[GrievanceTicket]:
identities_to_remove_with_approve_status
)
individual_data_with_approve_status["payment_channels"] = payment_channels_with_approve_status
individual_data_with_approve_status["payment_channels_to_remove"] = (
payment_channels_to_remove_with_approve_status
)
individual_data_with_approve_status[
"payment_channels_to_remove"
] = payment_channels_to_remove_with_approve_status
individual_data_with_approve_status["payment_channels_to_edit"] = prepare_edit_payment_channel(
payment_channels_to_edit
)
individual_data_with_approve_status["previous_payment_channels"] = prepare_previous_payment_channels(
payment_channels_to_remove_with_approve_status
)
individual_data_with_approve_status["delivery_mechanism_data"] = delivery_mechanism_data_with_approve_status
individual_data_with_approve_status["delivery_mechanism_data_to_remove"] = (
delivery_mechanism_data_to_remove_with_approve_status
)
individual_data_with_approve_status[
"delivery_mechanism_data_to_remove"
] = delivery_mechanism_data_to_remove_with_approve_status
individual_data_with_approve_status["delivery_mechanism_data_to_edit"] = prepare_edit_delivery_mechanism_data(
delivery_mechanism_data_to_edit
)
Expand Down Expand Up @@ -263,19 +263,19 @@ def update(self) -> GrievanceTicket:
identities_to_remove_with_approve_status
)
individual_data_with_approve_status["payment_channels"] = payment_channels_with_approve_status
individual_data_with_approve_status["payment_channels_to_remove"] = (
payment_channels_to_remove_with_approve_status
)
individual_data_with_approve_status[
"payment_channels_to_remove"
] = payment_channels_to_remove_with_approve_status
individual_data_with_approve_status["payment_channels_to_edit"] = prepare_edit_payment_channel(
payment_channels_to_edit
)
individual_data_with_approve_status["previous_payment_channels"] = prepare_previous_payment_channels(
payment_channels_to_remove_with_approve_status
)
individual_data_with_approve_status["delivery_mechanism_data"] = delivery_mechanism_data_with_approve_status
individual_data_with_approve_status["delivery_mechanism_data_to_remove"] = (
delivery_mechanism_data_to_remove_with_approve_status
)
individual_data_with_approve_status[
"delivery_mechanism_data_to_remove"
] = delivery_mechanism_data_to_remove_with_approve_status
individual_data_with_approve_status["delivery_mechanism_data_to_edit"] = prepare_edit_delivery_mechanism_data(
delivery_mechanism_data_to_edit
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def _create_workbook(self) -> openpyxl.Workbook:
return wb

def _add_version(self) -> None:
self.ws_meta[XlsxVerificationExportService.VERSION_CELL_NAME_COORDINATES] = (
XlsxVerificationExportService.VERSION_CELL_NAME
)
self.ws_meta[
XlsxVerificationExportService.VERSION_CELL_NAME_COORDINATES
] = XlsxVerificationExportService.VERSION_CELL_NAME
self.ws_meta[XlsxVerificationExportService.VERSION_CELL_COORDINATES] = XlsxVerificationExportService.VERSION

def _to_received_column(self, payment_record_verification: PaymentVerification) -> Optional[str]:
Expand Down Expand Up @@ -168,7 +168,7 @@ def _add_data_validation(self) -> None:
self.dv_received = DataValidation(type="list", formula1='"YES,NO"', allow_blank=False)
self.dv_received.add(f"B2:B{len(self.ws_export_list['B'])}")
self.ws_export_list.add_data_validation(self.dv_received)
self.ws_export_list["B2" : f"B{len(self.ws_export_list['B'])}"]
self.ws_export_list["B2":f"B{len(self.ws_export_list['B'])}"]

def generate_workbook(self) -> openpyxl.Workbook:
self._create_workbook()
Expand Down
8 changes: 4 additions & 4 deletions src/hct_mis_api/apps/periodic_data_update/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ def upload(self, request: Request, *args: Any, **kwargs: Any) -> Response:
if serializer.is_valid():
serializer.validated_data["created_by"] = request.user
try:
serializer.validated_data["template"] = (
PeriodicDataUpdateImportService.read_periodic_data_update_template_object(
serializer.validated_data["file"]
)
serializer.validated_data[
"template"
] = PeriodicDataUpdateImportService.read_periodic_data_update_template_object(
serializer.validated_data["file"]
)
except DjangoValidationError as e:
return Response(
Expand Down
6 changes: 3 additions & 3 deletions src/hct_mis_api/apps/steficon/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ def diff(self, request: HttpRequest, pk: UUID) -> Union[HttpResponseRedirect, Te
context["next"] = None

context["state"] = state
context["title"] = (
f"Change #{state.version} on {state.timestamp.strftime('%d, %b %Y at %H:%M')} by {state.updated_by}"
)
context[
"title"
] = f"Change #{state.version} on {state.timestamp.strftime('%d, %b %Y at %H:%M')} by {state.updated_by}"
return TemplateResponse(request, "admin/steficon/rule/diff.html", context)
except Exception as e:
logger.exception(e)
Expand Down
4 changes: 3 additions & 1 deletion src/hct_mis_api/apps/targeting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ class TargetingCriteriaRuleFilter(TimeStampedUUIDModel, TargetingCriteriaFilterB
@property
def is_social_worker_program(self) -> bool:
try:
return self.targeting_criteria_rule.targeting_criteria.payment_plan.program_cycle.program.is_social_worker_program
return (
self.targeting_criteria_rule.targeting_criteria.payment_plan.program_cycle.program.is_social_worker_program
)
except (
AttributeError,
TargetingCriteriaRuleFilter.targeting_criteria_rule.RelatedObjectDoesNotExist,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def generate_workbook(self) -> Workbook:
return self.workbook

def _add_version(self) -> None:
self.ws_meta[XlsxExportTargetingService.VERSION_CELL_NAME_COORDINATES] = (
XlsxExportTargetingService.VERSION_CELL_NAME
)
self.ws_meta[
XlsxExportTargetingService.VERSION_CELL_NAME_COORDINATES
] = XlsxExportTargetingService.VERSION_CELL_NAME
self.ws_meta[XlsxExportTargetingService.VERSION_CELL_COORDINATES] = XlsxExportTargetingService.VERSION

def _create_workbook(self) -> openpyxl.Workbook:
Expand Down
37 changes: 17 additions & 20 deletions src/hct_mis_api/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,23 @@

DATABASE_ROUTERS = ("hct_mis_api.apps.core.dbrouters.DbRouter",)

MIDDLEWARE = (
[
# "hct_mis_api.middlewares.deployment.DisableTrafficDuringMigrationsMiddleware",
]
+ [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"hijack.middleware.HijackUserMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
# "django.middleware.clickjacking.XFrameOptionsMiddleware",
# Replace the default XFrameOptionsMiddleware with the custom one to enable Dashboard iframe
"hct_mis_api.middlewares.xframe.AllowSpecificIframeDomainsMiddleware",
"hct_mis_api.middlewares.sentry.SentryScopeMiddleware",
"hct_mis_api.middlewares.version.VersionMiddleware",
]
)
MIDDLEWARE = [
# "hct_mis_api.middlewares.deployment.DisableTrafficDuringMigrationsMiddleware",
] + [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"hijack.middleware.HijackUserMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
# "django.middleware.clickjacking.XFrameOptionsMiddleware",
# Replace the default XFrameOptionsMiddleware with the custom one to enable Dashboard iframe
"hct_mis_api.middlewares.xframe.AllowSpecificIframeDomainsMiddleware",
"hct_mis_api.middlewares.sentry.SentryScopeMiddleware",
"hct_mis_api.middlewares.version.VersionMiddleware",
]
if not DEBUG:
MIDDLEWARE.append("csp.contrib.rate_limiting.RateLimitedCSPMiddleware")

Expand Down
5 changes: 2 additions & 3 deletions tests/selenium/accountability/test_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ def test_smoke_accountability_communication_details(
in pageAccountabilityCommunicationDetails.getLabelCreatedBy().text
)

assert (
"You got credit of USD 100 Greetings, we have sent you USD 100 in your registered account on 2022-09-19 20:00:00 UTC"
in pageAccountabilityCommunicationDetails.getCommunicationMessageDetails().text.replace("\n", " ")
assert "You got credit of USD 100 Greetings, we have sent you USD 100 in your registered account on 2022-09-19 20:00:00 UTC" in pageAccountabilityCommunicationDetails.getCommunicationMessageDetails().text.replace(
"\n", " "
)

assert (
Expand Down
60 changes: 30 additions & 30 deletions tests/selenium/country_dashboard/test_country_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,36 +68,36 @@ def test_smoke_country_dashboard(self, pageCountryDashboard: CountryDashboard, b
pageCountryDashboard.getNavCountryDashboard().click()
pageCountryDashboard.switch_to_dashboard_iframe()
assert pageCountryDashboard.get_total_amount_paid().text != "", "Expected total amount paid to be populated."
assert pageCountryDashboard.get_total_amount_paid_local().text != "", (
"Expected total amount in local paid to be populated."
)
assert int(pageCountryDashboard.get_number_of_payments().text) > 0, (
"Expected number of payments to be greater than zero."
)
assert pageCountryDashboard.get_outstanding_payments().text == "0.00 USD", (
"Expected outstanding payments to be 0.00 USD"
)
assert int(pageCountryDashboard.get_households_reached().text) > 0, (
"Expected households reached to be greater than zero."
)
assert (
pageCountryDashboard.get_total_amount_paid_local().text != ""
), "Expected total amount in local paid to be populated."
assert (
int(pageCountryDashboard.get_number_of_payments().text) > 0
), "Expected number of payments to be greater than zero."
assert (
pageCountryDashboard.get_outstanding_payments().text == "0.00 USD"
), "Expected outstanding payments to be 0.00 USD"
assert (
int(pageCountryDashboard.get_households_reached().text) > 0
), "Expected households reached to be greater than zero."
assert int(pageCountryDashboard.get_pwd_reached().text) == 0, "Expected PWD reached to be zero."
assert int(pageCountryDashboard.get_children_reached().text) > 0, (
"Expected children reached to be greater than zero."
)
assert int(pageCountryDashboard.get_individuals_reached().text) > 0, (
"Expected individuals reached to be greater than zero."
)
assert pageCountryDashboard.driver.find_element(By.ID, "payments-by-fsp").is_displayed(), (
"Payments by FSP chart should be displayed."
)
assert pageCountryDashboard.driver.find_element(By.ID, "payments-by-delivery").is_displayed(), (
"Payments by Delivery chart should be displayed."
)
assert pageCountryDashboard.driver.find_element(By.ID, "payments-by-sector").is_displayed(), (
"Payments by Sector chart should be displayed."
)
assert pageCountryDashboard.driver.find_element(By.ID, "payments-by-admin1").is_displayed(), (
"Payments by Admin 1 chart should be displayed."
)
assert (
int(pageCountryDashboard.get_children_reached().text) > 0
), "Expected children reached to be greater than zero."
assert (
int(pageCountryDashboard.get_individuals_reached().text) > 0
), "Expected individuals reached to be greater than zero."
assert pageCountryDashboard.driver.find_element(
By.ID, "payments-by-fsp"
).is_displayed(), "Payments by FSP chart should be displayed."
assert pageCountryDashboard.driver.find_element(
By.ID, "payments-by-delivery"
).is_displayed(), "Payments by Delivery chart should be displayed."
assert pageCountryDashboard.driver.find_element(
By.ID, "payments-by-sector"
).is_displayed(), "Payments by Sector chart should be displayed."
assert pageCountryDashboard.driver.find_element(
By.ID, "payments-by-admin1"
).is_displayed(), "Payments by Admin 1 chart should be displayed."

pageCountryDashboard.switch_to_default_content()
12 changes: 6 additions & 6 deletions tests/unit/apps/payment/test_fsp_in_payment_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ def test_being_able_to_get_possible_delivery_mechanisms(self) -> None:
assert response is not None and "data" in response
all_delivery_mechanisms = response["data"]["allDeliveryMechanisms"]
assert all_delivery_mechanisms is not None, response
assert all(key in entry for entry in all_delivery_mechanisms for key in ["name", "value"]), (
all_delivery_mechanisms
)
assert all(
key in entry for entry in all_delivery_mechanisms for key in ["name", "value"]
), all_delivery_mechanisms

def test_providing_non_unique_delivery_mechanisms(self) -> None:
payment_plan = PaymentPlanFactory(
Expand Down Expand Up @@ -964,9 +964,9 @@ def test_getting_volume_by_delivery_mechanism(self) -> None:
"paymentPlanId": self.encoded_payment_plan_id,
},
)
assert "errors" not in new_get_volume_by_delivery_mechanism_response, (
new_get_volume_by_delivery_mechanism_response
)
assert (
"errors" not in new_get_volume_by_delivery_mechanism_response
), new_get_volume_by_delivery_mechanism_response

new_data = new_get_volume_by_delivery_mechanism_response["data"]["paymentPlan"]["volumeByDeliveryMechanism"]
assert len(new_data) == 3
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/apps/payment/test_import_verifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ def test_import_valid_status_changed_received_yes_full(self) -> None:
payment_verification = PaymentVerification.objects.get(payment_id=payment_record_id)
self.assertEqual(payment_verification.status, PaymentVerification.STATUS_PENDING)
wb.active[f"{XlsxVerificationExportService.RECEIVED_COLUMN_LETTER}2"] = "YES"
wb.active[f"{XlsxVerificationExportService.RECEIVED_AMOUNT_COLUMN_LETTER}2"] = (
payment_verification.payment.delivered_quantity
)
wb.active[
f"{XlsxVerificationExportService.RECEIVED_AMOUNT_COLUMN_LETTER}2"
] = payment_verification.payment.delivered_quantity
with NamedTemporaryFile() as tmp:
wb.save(tmp.name)
file = io.BytesIO(tmp.read())
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/apps/payment/test_payment_plan_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,9 @@ def test_receiving_reconciliations_from_fsp(self, mock_get_exchange_rate: Any) -
"file": uploaded_file,
},
)
assert "errors" in import_mutation_response["data"]["importXlsxPaymentPlanPaymentListPerFsp"], (
import_mutation_response
)
assert (
"errors" in import_mutation_response["data"]["importXlsxPaymentPlanPaymentListPerFsp"]
), import_mutation_response
assert (
import_mutation_response["data"]["importXlsxPaymentPlanPaymentListPerFsp"]["errors"][0][
"message"
Expand Down
Loading

0 comments on commit 0f27aad

Please sign in to comment.