Example #1
0
def test_new_teacher(mock_record, requested):
    mock_profile = mock.Mock(id=2, notify_joined_my_village=requested)
    mock_teacher = mock.Mock(id=3)
    mock_student = mock.Mock(id=4)
    record.new_teacher(mock_profile, mock_teacher, mock_student)

    mock_record.assert_called_with(
        mock_profile,
        'new teacher',
        triggering=requested,
        data={'teacher-id': 3, 'student-id': 4},
        )
Example #2
0
    def test_generic_subject_multiple_students(self, recip):
        """Generic subject if multiple notification types, multiple students."""
        rel = factories.RelationshipFactory.create(from_profile=recip)
        other_rel = factories.RelationshipFactory.create()
        factories.RelationshipFactory.create(
            from_profile=recip, to_profile=other_rel.student)

        record.added_to_village(recip, other_rel.elder, other_rel.student)
        record.new_teacher(recip, other_rel.elder, rel.student)

        assert base.send(recip.id)
        assert len(mail.outbox) == 1
        assert mail.outbox[0].subject == "New activity in two of your villages."
    def test_generic_subject_single_student(self, recip):
        """Generic subject if multiple notification types, single student."""
        rel = factories.RelationshipFactory.create(
            from_profile=recip, to_profile__name='A Student')
        other_rel = factories.RelationshipFactory.create(
            to_profile=rel.student)

        record.added_to_village(recip, other_rel.elder, rel.student)
        record.new_teacher(recip, other_rel.elder, rel.student)

        assert base.send(recip.id)
        assert len(mail.outbox) == 1
        assert mail.outbox[0].subject == "New activity in A Student's village."
def test_new_teacher(mock_record, requested):
    mock_profile = mock.Mock(id=2, notify_joined_my_village=requested)
    mock_teacher = mock.Mock(id=3)
    mock_student = mock.Mock(id=4)
    record.new_teacher(mock_profile, mock_teacher, mock_student)

    mock_record.assert_called_with(
        mock_profile,
        'new teacher',
        triggering=requested,
        data={
            'teacher-id': 3,
            'student-id': 4
        },
    )
    def test_new_teachers(self, params, recip):
        """Test subject/body for new-teacher notifications."""
        student_names, teacher_names = params['scenario']
        teacher_profiles = []
        context = {}
        for teacher_name in teacher_names:
            teacher_profiles.append(
                factories.ProfileFactory.create(name=teacher_name))
        for student_name in student_names:
            rel = factories.RelationshipFactory.create(
                from_profile=recip, to_profile__name=student_name)
            context[student_name + 'Url'] = reverse(
                'village', kwargs={'student_id': rel.to_profile_id})
            for teacher in teacher_profiles:
                factories.RelationshipFactory.create(from_profile=teacher,
                                                     to_profile=rel.student)
                record.new_teacher(recip, teacher, rel.student)

        assert base.send(recip.id)
        self.assert_multi_email(params['subject'], params['html'],
                                params['text'], context)
Example #6
0
    def test_new_teachers(self, params, recip):
        """Test subject/body for new-teacher notifications."""
        student_names, teacher_names = params['scenario']
        teacher_profiles = []
        context = {}
        for teacher_name in teacher_names:
            teacher_profiles.append(
                factories.ProfileFactory.create(name=teacher_name))
        for student_name in student_names:
            rel = factories.RelationshipFactory.create(
                from_profile=recip, to_profile__name=student_name)
            context[student_name + 'Url'] = reverse(
                'village', kwargs={'student_id': rel.to_profile_id})
            for teacher in teacher_profiles:
                factories.RelationshipFactory.create(
                    from_profile=teacher, to_profile=rel.student)
                record.new_teacher(recip, teacher, rel.student)

        assert base.send(recip.id)
        self.assert_multi_email(
            params['subject'], params['html'], params['text'], context)
    def test_footer(self, recip):
        """Footer links to profile."""
        rel = factories.RelationshipFactory.create(
            from_profile=recip, to_profile__name='A Student')
        other_rel = factories.RelationshipFactory.create(
            to_profile=rel.student)

        record.new_teacher(recip, other_rel.elder, rel.student)

        assert base.send(recip.id)
        self.assert_multi_email(
            html_snippets=[
                '<p>Don\'t want email notifications from Portfoliyo? '
                '<a href="%(url)s">Edit your profile</a>.</p>'
            ],
            text_snippets=[
                "----\n"
                "Don't want email notifications from Portfoliyo? "
                "Edit your profile: %(base)s%(url)s"
            ],
            snippet_context={'url': reverse('edit_profile')},
        )
Example #8
0
    def test_footer(self, recip):
        """Footer links to profile."""
        rel = factories.RelationshipFactory.create(
            from_profile=recip, to_profile__name='A Student')
        other_rel = factories.RelationshipFactory.create(
            to_profile=rel.student)

        record.new_teacher(recip, other_rel.elder, rel.student)

        assert base.send(recip.id)
        self.assert_multi_email(
            html_snippets=[
                '<p>Don\'t want email notifications from Portfoliyo? '
                '<a href="%(url)s">Edit your profile</a>.</p>'
                ],
            text_snippets=[
                "----\n"
                "Don't want email notifications from Portfoliyo? "
                "Edit your profile: %(base)s%(url)s"
                ],
            snippet_context={'url': reverse('edit_profile')},
            )