Skip to content

Commit

Permalink
add test to specifically check the ratio calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlukasse committed May 24, 2022
1 parent 33b26ed commit 969d476
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/models_tests/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ func TestRetrieveStatsBySourceIdAndCohortIdAndConceptIds(t *testing.T) {
}
}

func TestRetrieveStatsBySourceIdAndCohortIdAndConceptIdsCheckRatio(t *testing.T) {
setUp(t)
filterIds := make([]int, 1)
filterIds[0] = genderConceptId
conceptsStats, _ := conceptModel.RetrieveStatsBySourceIdAndCohortIdAndConceptIds(testSourceId,
largestCohort.Id,
filterIds)
// simple test: in the test data we keep the gender concept *missing* at a ratio of 1/3 for the largest cohort. Here
// we check if the missing ratio calculation is working correctly:
if len(conceptsStats) != 1 {
t.Errorf("Found %d", len(conceptsStats))
}
if conceptsStats[0].NmissingRatio != 1.0/3.0 {
t.Errorf("Found wrong ratio %f", conceptsStats[0].NmissingRatio)
}
}

func TestRetrieveInfoBySourceIdAndConceptIds(t *testing.T) {
setUp(t)
conceptsInfo, _ := conceptModel.RetrieveInfoBySourceIdAndConceptIds(testSourceId,
Expand Down

0 comments on commit 969d476

Please sign in to comment.