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_letter_without_text(client): """Verify that view returns 404 if no letter text available.""" letter = MicromastersProgramCommendationFactory.create() signatory = ProgramLetterSignatoryFactory.create(program_page__program=letter.program) program_letter_logo = ImageFactory() signatory.program_page.program_letter_logo = program_letter_logo signatory.program_page.save() resp = client.get(program_letter_url(letter.uuid)) assert resp.status_code == status.HTTP_404_NOT_FOUND
def test_program_letter_without_text(client): """Verify that view returns 404 if no letter text available.""" letter = MicromastersProgramCommendationFactory.create() signatory = ProgramLetterSignatoryFactory.create( program_page__program=letter.program) program_letter_logo = ImageFactory() signatory.program_page.program_letter_logo = program_letter_logo signatory.program_page.save() resp = client.get(program_letter_url(letter.uuid)) assert resp.status_code == status.HTTP_404_NOT_FOUND
def test_program_letter_without_signatories(client): """Verify that view returns 404 if no signatory available.""" letter = MicromastersProgramCommendationFactory.create() resp = client.get(program_letter_url(letter.uuid)) assert resp.status_code == status.HTTP_404_NOT_FOUND