def create_checkpoints(self):
     """Checkpoints should gain additional properties as client dicts."""
     config = {
        'project_tasklist_template': [
             {
                 'name': "Project Foo",
                 'label': 'demo_project__foo',
                 'body': "foo",
                 'tasks': [],
             },
             {
                 'name': "Project Bar",
                 'label': 'demo_project__bar',
                 'body': "bar",
                 'tasks': [],
             },
         ],
     }
     Program.mock_program_config('demo-program', config)
     checkpoints = (
         Checkpoint.create(
             parent_id='Project_foo', ordinal=1,
             program_label='demo-program',
             **config['project_tasklist_template'][0]
         ),
         Checkpoint.create(
             parent_id='Project_bar', ordinal=2,
             program_label='demo-program',
             **config['project_tasklist_template'][1]
         ),
     )
     Checkpoint.put_multi(checkpoints)
     return checkpoints
Пример #2
0
 def test_checkpoint_client_dict(self):
     """Checkpoints should gain additional properties as client dicts."""
     checkpoint_template = {
         'name': "Project Foo",
         'label': 'demo_project__foo',
         'body': "foo",
         'tasks': [],
     }
     config = {'project_tasklist_template': [checkpoint_template]}
     Program.mock_program_config('demo-program', config)
     checkpoint = Checkpoint.create(parent_id='Project_foo',
                                    ordinal=1,
                                    program_label='demo-program',
                                    **checkpoint_template)
     self.assertIsNone(getattr(checkpoint, 'body', None))
     self.assertIsNotNone(checkpoint.to_client_dict()['body'])
Пример #3
0
    def create_with_project_cohort(self):
        checkpoint_template = {
            'name': "Survey Foo",
            'label': 'demo_survey__foo',
            'body': "foo",
            'tasks': [],
        }
        config = {
            'surveys': [
                {
                    'name': "Student Module",
                    'survey_tasklist_template': [checkpoint_template],
                },
            ],
        }
        Program.mock_program_config(self.program_label, config)

        org = Organization.create(name='Foo Org')
        org.put()

        project = Project.create(
            program_label=self.program_label,
            organization_id=org.uid,
        )
        project.put()

        pc = ProjectCohort.create(
            program_label=self.program_label,
            organization_id=org.uid,
            project_id=project.uid,
        )
        pc.put()

        checkpoint = Checkpoint.create(parent_id='Survey_foo',
                                       ordinal=1,
                                       program_label=self.program_label,
                                       organization_id=org.uid,
                                       project_id=project.uid,
                                       project_cohort_id=pc.uid,
                                       status='incomplete',
                                       **checkpoint_template)
        checkpoint.put()

        pc.update_cached_properties()

        return org, project, pc, checkpoint