def test_successful_generation(self): ProgramFactory.create( title="edX Demonstration Program", course_runs=[self.new_course_run], authoring_organizations=self.orgs, site=self.site, ) call_command(command_name=COMMAND) assert len(ProgramCertificate.objects.all()) > 0
def test_get_program_details(self): program_uuid = uuid.uuid4() unused_program_uuid = uuid.uuid4() program = ProgramFactory.create(uuid=program_uuid, site=self.site) details = get_program_details_by_uuid(uuid=program_uuid, site=program.site) self.assertIsNotNone(details) self.assertIsInstance(details, ProgramDetails) details = get_program_details_by_uuid(uuid=unused_program_uuid, site=program.site) self.assertIsNone(details)
def test_multiple_programs(self): """ Test that multiple programs can appear, in progress and completed """ # Create a second program, and delete the first one's certificate new_course = CourseFactory.create(site=self.site) new_course_run = CourseRunFactory.create(course=new_course) new_program = ProgramFactory.create(title='ZTestProgram', course_runs=[new_course_run], authoring_organizations=self.orgs, site=self.site) new_course_cert = CourseCertificateFactory.create(course_id=new_course_run.key, site=self.site) new_program_cert = ProgramCertificateFactory.create(program_uuid=new_program.uuid, site=self.site) # Make a new user credential UserCredentialFactory.create( username=self.user.username, credential_content_type=self.program_credential_content_type, credential=new_course_cert ) # Make a new program credential UserCredentialFactory.create( username=self.user.username, credential_content_type=self.program_credential_content_type, credential=new_program_cert ) self.program_user_credential.delete() response = self.client.get(reverse('records:index')) self.assertEqual(response.status_code, 200) program_data = json.loads(response.context_data['programs']) expected_program_data = [ { 'name': self.program.title, 'partner': 'TestOrg1, TestOrg2', 'uuid': self.program.uuid.hex, 'type': slugify(self.program.type), 'completed': False, 'empty': False, }, { 'name': new_program.title, 'partner': 'TestOrg1, TestOrg2', 'uuid': new_program.uuid.hex, 'type': slugify(new_program.type), 'completed': True, 'empty': False, } ] self.assertEqual(program_data, expected_program_data)