def test_valid_program_letter(client): """Test that a request for a valid program letter with signatories results in a 200""" letter = MicromastersProgramCommendationFactory.create() program = letter.program signatory = ProgramLetterSignatoryFactory.create(program_page__program=program) program_letter_logo = ImageFactory() signatory.program_page.program_letter_logo = program_letter_logo program_letter_text = "<p>some example text</p>" signatory.program_page.program_letter_text = program_letter_text signatory.program_page.save() resp = client.get(program_letter_url(letter.uuid)) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'program_title': program.title, 'letter_logo': program_letter_logo, 'name': letter.user.profile.full_name, 'letter_text': program_letter_text, 'signatories': [signatory], 'letter': letter, }, resp.context_data ) assert reverse('program_letter', args=[letter.uuid]) in resp.content.decode('utf-8')
def test_valid_program_letter(client): """Test that a request for a valid program letter with signatories results in a 200""" letter = MicromastersProgramCommendationFactory.create() program = letter.program signatory = ProgramLetterSignatoryFactory.create( program_page__program=program) program_letter_logo = ImageFactory() signatory.program_page.program_letter_logo = program_letter_logo program_letter_text = "<p>some example text</p>" signatory.program_page.program_letter_text = program_letter_text signatory.program_page.save() resp = client.get(program_letter_url(letter.uuid)) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'program_title': program.title, 'letter_logo': program_letter_logo, 'name': letter.user.profile.full_name, 'letter_text': program_letter_text, 'signatories': [signatory], 'letter': letter, }, resp.context_data) assert reverse('program_letter', args=[letter.uuid]) in resp.content.decode('utf-8')
def test_program_record(client): """Test that a request for program record results in 200""" enrollment = ProgramEnrollmentFactory.create() resp = client.get( reverse("grade_records", kwargs=dict(record_hash=enrollment.hash))) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'record_hash': enrollment.hash, 'program_title': enrollment.program.title, 'program_status': 'partially', 'profile': { 'username': enrollment.user.username }, 'last_updated': '' }, resp.context_data)
def test_program_record(client): """Test that a request for program record results in 200""" enrollment = ProgramEnrollmentFactory.create() resp = client.get(reverse("grade_records", kwargs=dict(record_hash=enrollment.hash))) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'record_hash': enrollment.hash, 'program_title': enrollment.program.title, 'program_status': 'partially', 'profile': { 'username': enrollment.user.username }, 'last_updated': '' }, resp.context_data )
def test_valid_program_certificate_200(client): """Test that a request for a valid program certificate with signatories results in a 200""" certificate = MicromastersProgramCertificateFactory.create() signatory = ProgramCertificateSignatoriesFactory.create(program_page__program=certificate.program) resp = client.get(program_certificate_url(certificate.hash)) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'certificate_hash': certificate.hash, 'program_title': certificate.program.title, 'name': certificate.user.profile.full_name, 'signatories': [signatory], 'certificate': certificate }, resp.context_data ) assert reverse('program-certificate', args=[certificate.hash]) in resp.content.decode('utf-8')
def test_valid_program_certificate_200(client): """Test that a request for a valid program certificate with signatories results in a 200""" certificate = MicromastersProgramCertificateFactory.create() signatory = ProgramCertificateSignatoriesFactory.create( program_page__program=certificate.program) resp = client.get(program_certificate_url(certificate.hash)) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'certificate_hash': certificate.hash, 'program_title': certificate.program.title, 'name': certificate.user.profile.full_name, 'signatories': [signatory], 'certificate': certificate }, resp.context_data) assert reverse('program-certificate', args=[certificate.hash]) in resp.content.decode('utf-8')
def test_program_record(client): """Test that a request for program record results in 200""" user = UserFactory.create() enrollment = ProgramEnrollmentFactory.create(user=user) client.force_login(user) resp = client.get( reverse("grade_records", kwargs=dict(enrollment_id=enrollment.id))) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'is_public': False, 'is_owner': True, 'program_title': enrollment.program.title, 'program_status': 'partially', 'profile': { 'username': enrollment.user.username } }, resp.context_data)
def test_is_subset_dict(self): """ Tests that is_subset_dict properly determines whether or not a dict is a subset of another dict """ d1 = {'a': 1, 'b': 2, 'c': {'d': 3}} d2 = {'a': 1, 'b': 2, 'c': {'d': 3}, 'e': 4} assert is_subset_dict(d1, d2) assert is_subset_dict(d1, d1) assert not is_subset_dict(d2, d1) new_dict = dict(d1) new_dict['f'] = 5 assert not is_subset_dict(new_dict, d2) new_dict = dict(d1) new_dict['a'] = 2 assert not is_subset_dict(new_dict, d2) new_dict = dict(d1) new_dict['c']['d'] = 123 assert not is_subset_dict(new_dict, d2)