@@ -566,39 +566,68 @@ func TestRetrieveBreakdownStatsBySourceIdAndCohortIdWithResultsWithOnePersonTwoH
566
566
567
567
func TestGetTeamProjectsThatMatchAllCohortDefinitionIdsOnlyDefaultMatch (t * testing.T ) {
568
568
setUp (t )
569
- cohortDefinitionId := 2
569
+ cohortDefinitionId := 2 // 'Medium cohort' in test_data_atlas.sql
570
570
filterCohortPairs := []utils.CustomDichotomousVariableDef {
571
571
{
572
572
CohortDefinitionId1 : smallestCohort .Id ,
573
573
CohortDefinitionId2 : largestCohort .Id ,
574
574
ProvidedName : "test" },
575
575
}
576
- uniqueCohortDefinitionIdsList := utils .GetUniqueCohortDefinitionIdsListFromRequest ([]int {cohortDefinitionId }, filterCohortPairs )
576
+ uniqueCohortDefinitionIdsList := utils .GetUniqueCohortDefinitionIdsList ([]int {cohortDefinitionId }, filterCohortPairs )
577
+ if len (uniqueCohortDefinitionIdsList ) != 3 {
578
+ t .Errorf ("Expected uniqueCohortDefinitionIdsList length to be 3" )
579
+ }
577
580
teamProjects , _ := cohortDefinitionModel .GetTeamProjectsThatMatchAllCohortDefinitionIds (uniqueCohortDefinitionIdsList )
578
581
if len (teamProjects ) != 1 || teamProjects [0 ] != "defaultteamproject" {
579
582
t .Errorf ("Expected to find only defaultteamproject" )
580
583
}
584
+
585
+ // Should also hold true if the uniqueCohortDefinitionIdsList is length 2 (which matches teamprojectX's cohort
586
+ // list length but not in contents):
587
+ filterCohortPairs = []utils.CustomDichotomousVariableDef {
588
+ {
589
+ CohortDefinitionId1 : 2 ,
590
+ CohortDefinitionId2 : largestCohort .Id ,
591
+ ProvidedName : "test" },
592
+ }
593
+ uniqueCohortDefinitionIdsList = utils .GetUniqueCohortDefinitionIdsList ([]int {cohortDefinitionId }, filterCohortPairs )
594
+ if len (uniqueCohortDefinitionIdsList ) != 2 {
595
+ t .Errorf ("Expected uniqueCohortDefinitionIdsList length to be 2" )
596
+ }
597
+ teamProjects , _ = cohortDefinitionModel .GetTeamProjectsThatMatchAllCohortDefinitionIds (uniqueCohortDefinitionIdsList )
598
+ if len (teamProjects ) != 1 || teamProjects [0 ] != "defaultteamproject" {
599
+ t .Errorf ("Expected to find only defaultteamproject" )
600
+ }
581
601
}
582
602
583
603
func TestGetTeamProjectsThatMatchAllCohortDefinitionIds (t * testing.T ) {
584
604
setUp (t )
585
- cohortDefinitionId := 2
605
+ cohortDefinitionId := 2 // 'Medium cohort' in test_data_atlas.sql
586
606
filterCohortPairs := []utils.CustomDichotomousVariableDef {
587
607
{
588
608
CohortDefinitionId1 : 2 ,
589
- CohortDefinitionId2 : 2 ,
609
+ CohortDefinitionId2 : 32 ,
590
610
ProvidedName : "test" },
591
611
}
592
- uniqueCohortDefinitionIdsList := utils .GetUniqueCohortDefinitionIdsListFromRequest ([]int {cohortDefinitionId }, filterCohortPairs )
612
+ uniqueCohortDefinitionIdsList := utils .GetUniqueCohortDefinitionIdsList ([]int {cohortDefinitionId }, filterCohortPairs )
613
+ if len (uniqueCohortDefinitionIdsList ) != 2 {
614
+ t .Errorf ("Expected uniqueCohortDefinitionIdsList length to be 2" )
615
+ }
593
616
teamProjects , _ := cohortDefinitionModel .GetTeamProjectsThatMatchAllCohortDefinitionIds (uniqueCohortDefinitionIdsList )
594
617
if len (teamProjects ) != 2 {
595
618
t .Errorf ("Expected to find two 'team projects' matching the cohort list, found %s" , teamProjects )
596
619
}
620
+ if ! utils .ContainsString (teamProjects , "defaultteamproject" ) {
621
+ t .Errorf ("Expected to find 'defaultteamproject' in the results, found %s" , teamProjects )
622
+ }
623
+ if ! utils .ContainsString (teamProjects , "teamprojectX" ) {
624
+ t .Errorf ("Expected to find 'teamprojectX' in the results, found %s" , teamProjects )
625
+ }
597
626
}
598
627
599
628
func TestGetCohortDefinitionIdsForTeamProject (t * testing.T ) {
600
629
setUp (t )
601
- testTeamProject := "teamprojectX "
630
+ testTeamProject := "teamprojectY "
602
631
allowedCohortDefinitionIds , _ := cohortDefinitionModel .GetCohortDefinitionIdsForTeamProject (testTeamProject )
603
632
if len (allowedCohortDefinitionIds ) != 1 {
604
633
t .Errorf ("Expected teamProject '%s' to have one cohort, but found %d" ,
@@ -633,7 +662,7 @@ func TestGetAllCohortDefinitionsAndStatsOrderBySizeDesc(t *testing.T) {
633
662
}
634
663
635
664
// some extra tests to cover also the teamProject option for this method:
636
- testTeamProject := "teamprojectX "
665
+ testTeamProject := "teamprojectY "
637
666
allowedCohortDefinitions , _ := cohortDefinitionModel .GetAllCohortDefinitionsAndStatsOrderBySizeDesc (testSourceId , testTeamProject )
638
667
if len (allowedCohortDefinitions ) != 1 {
639
668
t .Errorf ("Expected teamProject '%s' to have one cohort, but found %d" ,
0 commit comments