Skip to content

Commit

Permalink
update organization filter test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 authored and AdityaKhatri committed Jan 16, 2024
1 parent 8ce7ac2 commit bfd6a7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
9 changes: 5 additions & 4 deletions apps/assessment_registry/dashboard_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def resolve_assessment_by_data_collection_technique_and_geolocation(root: Assess
admin_level_id=models.F("assessment_registry__locations__admin_level_id"),
)
.annotate(count=Count("assessment_registry__locations"))
.values('data_collection_technique', 'geo_area', 'region', 'admin_level_id')
.values('data_collection_technique', 'geo_area', 'region', 'admin_level_id', 'count')
.order_by("assessment_registry__locations")
)

Expand All @@ -725,7 +725,7 @@ def resolve_assessment_by_sampling_approach_and_geolocation(root: AssessmentDash
admin_level_id=models.F("assessment_registry__locations__admin_level_id"),
)
.annotate(count=Count("assessment_registry__locations"))
.values('sampling_approach', 'geo_area', 'region', 'admin_level_id')
.values('sampling_approach', 'geo_area', 'region', 'admin_level_id', 'count')
.order_by("assessment_registry__locations")
)

Expand All @@ -740,7 +740,7 @@ def resolve_assessment_by_proximity_and_geolocation(root: AssessmentDashboardSta
admin_level_id=models.F("assessment_registry__locations__admin_level_id"),
)
.annotate(count=Count("assessment_registry__locations"))
.values('proximity', 'geo_area', 'region', 'admin_level_id')
.values('proximity', 'geo_area', 'region', 'admin_level_id', 'count')
.order_by("assessment_registry__locations")
)

Expand All @@ -755,6 +755,7 @@ def resolve_assessment_by_unit_of_analysis_and_geolocation(root: AssessmentDashb
admin_level_id=models.F("assessment_registry__locations__admin_level_id"),
)
.annotate(count=Count("assessment_registry__locations"))
.values('geo_area', 'region', 'admin_level_id', 'unit_of_analysis', 'count')
.order_by("assessment_registry__locations")
)

Expand All @@ -769,7 +770,7 @@ def resolve_assessment_by_unit_of_reporting_and_geolocation(root: AssessmentDash
admin_level_id=models.F("assessment_registry__locations__admin_level_id"),
)
.annotate(count=Count("assessment_registry__locations"))
.values('unit_of_reporting' 'geo_area', 'region', 'admin_level_id')
.values('unit_of_reporting', 'geo_area', 'region', 'admin_level_id')
.order_by("assessment_registry__locations")
)

Expand Down
6 changes: 6 additions & 0 deletions apps/assessment_registry/filter_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def filter_focuses(self, qs, _, value):
def filter_sectors(self, qs, _, value):
return qs if value is None else qs.filter(sectors__overlap=value)

def filter_details_type(self, qs, _, value):
return qs if value is None else qs.filter(details_type__overlap=value)

def filter_coordinated_joint(self, qs, _, value):
return qs if value is None else qs.filter(coordinated_joint__overlap=value)


AssessmentDashboardFilterDataType, AssessmentDashboardFilterDataInputType = generate_type_for_filter_set(
AssessmentDashboardFilterSet,
Expand Down
10 changes: 5 additions & 5 deletions apps/assessment_registry/tests/test_dashboard_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def _query_check(filter=None, **kwargs):
self.assertEqual(content["collectionTechniqueCount"][1]["dataCollectionTechnique"], "KEY_INFORMAT_INTERVIEW")
self.assertEqual(content["assessmentByOverTime"][0]["count"], 1)
self.assertEqual(content["assessmentByOverTime"][0]["date"], str(date.today()))
self.assertEqual(content["assessmentGeographicAreas"][0]["geoArea"], self.geo_area1.id)
self.assertEqual(content["assessmentGeographicAreas"][1]["geoArea"], self.geo_area2.id)
self.assertEqual(content["assessmentGeographicAreas"][0]["geoArea"], str(self.geo_area1.id))
self.assertEqual(content["assessmentGeographicAreas"][1]["geoArea"], str(self.geo_area2.id))
self.assertEqual(content["assessmentByOverTime"][0]["count"], 1)
self.assertEqual(content["assessmentByOverTime"][0]["date"], str(date.today()))
self.assertEqual(content["assessmentPerFrameworkPillar"][0]["date"], str(date.today()))
Expand All @@ -356,13 +356,13 @@ def _query_check(filter=None, **kwargs):
self.assertEqual(
content['assessmentByDataCollectionTechniqueAndGeolocation'][1]['dataCollectionTechnique'],
"KEY_INFORMAT_INTERVIEW")
self.assertEqual(content['assessmentByDataCollectionTechniqueAndGeolocation'][0]['geoArea'], self.geo_area1.id)
self.assertEqual(content['assessmentByDataCollectionTechniqueAndGeolocation'][1]['geoArea'], self.geo_area1.id)
self.assertEqual(content['assessmentByDataCollectionTechniqueAndGeolocation'][0]['geoArea'], str(self.geo_area1.id))
self.assertEqual(content['assessmentByDataCollectionTechniqueAndGeolocation'][1]['geoArea'], str(self.geo_area1.id))
self.assertEqual(content['assessmentByDataCollectionTechniqueAndGeolocation'][0]['count'], 1)
self.assertEqual(content['assessmentByDataCollectionTechniqueAndGeolocation'][1]['count'], 1)
self.assertEqual(content['assessmentByProximityAndGeolocation'][0]['count'], 2)
self.assertEqual(content['assessmentByProximityAndGeolocation'][0]['proximity'], "FACE_TO_FACE")
self.assertEqual(content['assessmentByProximityAndGeolocation'][0]['geoArea'], self.geo_area1.id)
self.assertEqual(content['assessmentByProximityAndGeolocation'][0]['geoArea'], str(self.geo_area1.id))
# assessment Dashboard tab 3
self.assertEqual(content['medianQualityScoreByAnalyticalDensityDate'][0]['sector'], "FOOD_SECURITY")
self.assertEqual(content['medianQualityScoreByAnalyticalDensityDate'][0]['sectorDisplay'], "Food Security")
Expand Down
8 changes: 4 additions & 4 deletions apps/organization/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def test_organization_query(self):
query MyQuery (
$verified: Boolean
$search: String
$usedInProject: ID
$usedInProjectByLead: ID
) {
organizations(
search: $search
verified: $verified
usedInProject: $usedInProject
usedInProjectByLead: $usedInProjectByLead
ordering: DESC_TITLE
) {
results {
Expand Down Expand Up @@ -98,10 +98,10 @@ def test_organization_query(self):
'verified': False,
}, [org7, org6, org5, org3, org1]),
(user, {
'usedInProject': str(project.id),
'usedInProjectByLead': str(project.id),
}, [org6, org5, org3, org2, org1]),
(non_member_user, {
'usedInProject': str(project.id),
'usedInProjectByLead': str(project.id),
# Return all the organizations (Filter not applied)
}, all_org),
# unaccent search
Expand Down

0 comments on commit bfd6a7c

Please sign in to comment.