Esempio n. 1
0
    def test_get_program_letter_url(self):
        """
        Test get_program_letter_url
        """
        mmtrack = MMTrack(
            user=self.user,
            program=self.program_financial_aid,
            edx_user_data=self.cached_edx_user_data
        )
        assert mmtrack.get_program_letter_url() == ""

        letter = MicromastersProgramCommendation.objects.create(
            user=self.user, program=self.program_financial_aid
        )
        assert mmtrack.get_program_letter_url() == ""

        signatory = ProgramLetterSignatoryFactory.create(program_page__program=letter.program)
        assert mmtrack.get_program_letter_url() == ""

        program_page = signatory.program_page

        program_page.program_letter_text = "<p> Some example test </p>"
        program_page.save()
        assert mmtrack.get_program_letter_url() == ""

        program_page.program_letter_logo = ImageFactory()
        program_page.save()

        assert mmtrack.get_program_letter_url() == reverse('program_letter', args=[letter.uuid])
Esempio n. 2
0
    def test_get_program_letter_url(self):
        """
        Test get_program_letter_url
        """
        mmtrack = MMTrack(
            user=self.user,
            program=self.program_financial_aid,
            edx_user_data=self.cached_edx_user_data
        )
        assert mmtrack.get_program_letter_url() == ""

        letter = MicromastersProgramCommendation.objects.create(
            user=self.user, program=self.program_financial_aid
        )
        assert mmtrack.get_program_letter_url() == ""

        signatory = ProgramLetterSignatoryFactory.create(program_page__program=letter.program)
        assert mmtrack.get_program_letter_url() == ""

        program_page = signatory.program_page

        program_page.program_letter_text = "<p> Some example test </p>"
        program_page.save()
        assert mmtrack.get_program_letter_url() == ""

        program_page.program_letter_logo = ImageFactory()
        program_page.save()

        assert mmtrack.get_program_letter_url() == reverse('program_letter', args=[letter.uuid])
Esempio n. 3
0
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')
Esempio n. 4
0
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')
Esempio n. 5
0
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
Esempio n. 6
0
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