Skip to content

Commit

Permalink
feature/fix-primary-operational-reports
Browse files Browse the repository at this point in the history
  • Loading branch information
delcroip committed Apr 23, 2024
1 parent 697cf1a commit ba29322
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
7 changes: 5 additions & 2 deletions policy/reports/primary_operational_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4301,15 +4301,18 @@
INNER JOIN "tblProduct" prod ON prod."ProdID" = pl."ProdID"
INNER JOIN "tblFamilies" fam ON fam."FamilyID" = pl."FamilyID"
INNER JOIN "tblInsuree" ins ON ins."InsureeID" = fam."InsureeID"
INNER JOIN "uvwLocations" l ON l."VillageId" = fam."LocationId"
INNER JOIN "tblLocations" v ON v."LocationId" = fam."LocationId"
INNER JOIN "tblLocations" w ON w."LocationId" = v."ParentLocationId"
INNER JOIN "tblLocations" d ON d."LocationId" = w."ParentLocationId"
INNER JOIN "tblLocations" r ON r."LocationId" = d."ParentLocationId"
LEFT JOIN "tblPremium" pr ON pr."PolicyID" = pl."PolicyID"
WHERE pl."ValidityTo" IS NULL
AND prod."ValidityTo" IS NULL
AND fam."ValidityTo" IS NULL
AND ins."ValidityTo" IS NULL
and pr."ValidityTo" IS NULL
AND (prod."ProdID" = %(ProdId)s OR %(ProdId)s = 0)
AND (l."RegionId" = %(LocationId)s OR l."DistrictId" = %(LocationId)s OR COALESCE(%(LocationId)s, 0) = 0 OR %(LocationId)s = 0)
AND (r."LocationId" = %(LocationId)s OR d."LocationId" = %(LocationId)s OR COALESCE(%(LocationId)s, 0) = 0 OR %(LocationId)s = 0)
GROUP BY prod."ProdID", prod."ProductCode";
"""

Expand Down
Empty file added policy/tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion policy/test_services.py → policy/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from policy.test_helpers import create_test_policy2, create_test_insuree_for_policy
from product.test_helpers import create_test_product, create_test_product_service, create_test_product_item
from location.test_helpers import create_test_health_facility
from .services import *
from policy.services import *
from medical_pricelist.test_helpers import (
create_test_item_pricelist,
create_test_service_pricelist
Expand Down
4 changes: 2 additions & 2 deletions policy/test_values.py → policy/tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from insuree.test_helpers import create_test_insuree, create_test_photo
from product.test_helpers import create_test_product
from insuree.models import Relation
from .values import *
from .test_helpers import create_test_policy
from policy.values import *
from policy.test_helpers import create_test_policy
from core.apps import CoreConfig
from dateutil.relativedelta import relativedelta

Expand Down
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions policy/tests/tests_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from core.test_helpers import create_test_interactive_user
from rest_framework import status
from rest_framework.test import APITestCase
from dataclasses import dataclass
from graphql_jwt.shortcuts import get_token
from core.models import User
from django.conf import settings


@dataclass
class DummyContext:
""" Just because we need a context to generate. """
user: User


class ReportAPITests( APITestCase):

admin_user = None
admin_token = None
POI_URL = f'/{settings.SITE_ROOT()}report/policy_primary_operational_indicators/pdf/?yearMonth=2019-04-01'
PR_URL = f'/{settings.SITE_ROOT()}report/policy_renewals/pdf/?date_start=2019-04-01&date_end=2019-04-30'
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.admin_user = create_test_interactive_user(username="testLocationAdmin")
cls.admin_token = get_token(cls.admin_user, DummyContext(user=cls.admin_user))

def test_primary_operational_indicators_report(self):
headers={"HTTP_AUTHORIZATION": f"Bearer {self.admin_token}"}
response = self.client.get(self.POI_URL, format='json', **headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_policy_renewal_report(self):
headers={"HTTP_AUTHORIZATION": f"Bearer {self.admin_token}"}
response = self.client.get(self.PR_URL, format='json', **headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)

0 comments on commit ba29322

Please sign in to comment.