Skip to content

Commit

Permalink
fix filters & update tests 💯 ⭐
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlo-mk committed Dec 16, 2024
1 parent 581be38 commit bea82a1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/hct_mis_api/apps/payment/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ def payment_plan_filter(self, qs: QuerySet, name: str, value: str) -> QuerySet:
)

def business_area_filter(self, qs: QuerySet, name: str, value: str) -> QuerySet:
return qs.filter(
Q(payment_verification_plan__payment_plan__business_area__slug=value)
| Q(payment_verification_plan__cash_plan__business_area__slug=value)
)
return qs.filter(payment_verification_plan__payment_plan__business_area__slug=value)


class PaymentVerificationPlanFilter(FilterSet):
Expand Down
1 change: 1 addition & 0 deletions src/hct_mis_api/apps/payment/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def resolve_target_population(self, info: Any) -> TargetPopulation:
return self.parent.target_population

def resolve_full_name(self, info: Any) -> str:
# TODO: add to test this one
return self.head_of_household.full_name if self.head_of_household else ""

def resolve_verification(self, info: Any) -> Optional[Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ def add_payment_verification_xlsx() -> PV:


def payment_verification_creator(channel: str = PaymentVerificationPlan.VERIFICATION_CHANNEL_MANUAL) -> PV:
user = User.objects.first()
registration_data_import = RegistrationDataImportFactory(
imported_by=User.objects.first(), business_area=BusinessArea.objects.first()
imported_by=user, business_area=BusinessArea.objects.first()
)
program = Program.objects.filter(name="Active Program").first()
household, individuals = create_household(
Expand All @@ -214,6 +215,7 @@ def payment_verification_creator(channel: str = PaymentVerificationPlan.VERIFICA
business_area=BusinessArea.objects.first(),
start_date=datetime.now() - relativedelta(months=1),
end_date=datetime.now() + relativedelta(months=1),
created_by=user,
)

payment_plan.unicef_id = "PP-0000-00-1122334"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
'data': {
'payment': {
'additionalCollectorName': None,
'fullName': 'First1 Mid1 Last1',
'reasonForUnsuccessfulPayment': 'reason 123',
'snapshotCollectorBankAccountNumber': None,
'snapshotCollectorBankName': None,
Expand All @@ -436,6 +437,7 @@
'data': {
'payment': {
'additionalCollectorName': 'AddCollectorName11',
'fullName': 'First2 Mid2 Last3',
'reasonForUnsuccessfulPayment': 'reason 222',
'snapshotCollectorBankAccountNumber': 'PrimaryCollBankNumber',
'snapshotCollectorBankName': 'PrimaryCollBankName',
Expand All @@ -452,6 +454,7 @@
'data': {
'payment': {
'additionalCollectorName': 'AddCollectorName22',
'fullName': 'First3 Mid3 Last3',
'reasonForUnsuccessfulPayment': 'reason 333',
'snapshotCollectorBankAccountNumber': 'AlternateCollBankNumber',
'snapshotCollectorBankName': 'AlternateCollBankName',
Expand Down
11 changes: 6 additions & 5 deletions tests/unit/apps/payment/test_all_payment_plan_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class TestPaymentPlanQueries(APITestCase):
query Payment($id: ID!) {
payment(id: $id) {
totalPersonsCovered
fullName
snapshotCollectorFullName
snapshotCollectorDeliveryPhoneNo
snapshotCollectorBankName
Expand Down Expand Up @@ -475,9 +476,9 @@ def test_payment_node_with_legacy_data(self) -> None:
dispersion_end_date=datetime(2023, 12, 10),
is_follow_up=False,
)
hoh_1 = IndividualFactory(household=None)
hoh_2 = IndividualFactory(household=None)
hoh_3 = IndividualFactory(household=None)
hoh_1 = IndividualFactory(household=None, given_name="First1", middle_name="Mid1", family_name="Last1")
hoh_2 = IndividualFactory(household=None, given_name="First2", middle_name="Mid2", family_name="Last3")
hoh_3 = IndividualFactory(household=None, given_name="First3", middle_name="Mid3", family_name="Last3")
household_1 = HouseholdFactory(head_of_household=hoh_1, size=5)
household_2 = HouseholdFactory(head_of_household=hoh_2, size=10)
household_3 = HouseholdFactory(head_of_household=hoh_3, size=15)
Expand Down Expand Up @@ -548,7 +549,7 @@ def test_payment_node_with_legacy_data(self) -> None:
)

def test_all_payment_verification_log_entries(self) -> None:
QUERY = """
query = """
query allPaymentVerificationLogEntries($objectId: UUID, $businessArea: String!) {
allPaymentVerificationLogEntries(objectId: $objectId, businessArea: $businessArea) {
totalCount
Expand Down Expand Up @@ -584,7 +585,7 @@ def test_all_payment_verification_log_entries(self) -> None:
)

self.snapshot_graphql_request(
request_string=QUERY,
request_string=query,
context={"user": self.user},
variables={"objectId": payment_plan_id, "businessArea": "afghanistan"},
)

0 comments on commit bea82a1

Please sign in to comment.