def test_completion_ids_exclude_testing(self): """Don't count testing pd as that participant being done.""" pid = self.test_create_portal_pd(testing=True) participant = Participant.create( id=SqlModel.convert_uid(pid), name='Pascal', organization_id='Organization_PERTS', ) participant.put() results = ParticipantData.completion_ids( project_cohort_id='ProjectCohort_12345678') self.assertEqual(results, [])
def test_get_survey_completion_ids(self): participants = {p.uid: p for p in self.mock_participants()} pds = self.mock_one_finished_one_unfinished(1) result = ParticipantData.completion_ids(survey_id=pds[0].survey_id) expected = [ { 'token': 'unfinished', 'percent_progress': '1', 'module': 1 }, { 'token': 'finished', 'percent_progress': '100', 'module': 1 }, ] self.assertEqual(result, expected)
def test_completion_ids(self): pid = self.test_create_portal_pd() participant = Participant.create( id=SqlModel.convert_uid(pid), name='Pascal', organization_id='Organization_PERTS', ) participant.put() results = ParticipantData.completion_ids( project_cohort_id='ProjectCohort_12345678') expected = [ { 'module': 1, 'percent_progress': '100', 'token': 'Pascal' }, { 'module': 2, 'percent_progress': '33', 'token': 'Pascal' }, ] self.assertEqual(results, expected)
def test_get_project_cohort_completion_ids(self): participants = {p.uid: p for p in self.mock_participants()} pds1 = self.mock_one_finished_one_unfinished(1) pds2 = self.mock_one_finished_one_unfinished(2) ProjectCohort( id=pds1[0].project_cohort_id, program_label=self.program_label, ).put() result = ParticipantData.completion_ids( project_cohort_id=pds1[0].project_cohort_id) expected = [ { 'token': 'unfinished', 'percent_progress': '1', 'module': 1 }, { 'token': 'finished', 'percent_progress': '100', 'module': 1 }, { 'token': 'unfinished', 'percent_progress': '1', 'module': 2 }, { 'token': 'finished', 'percent_progress': '100', 'module': 2 }, ] self.assertEqual(result, expected)