Example #1
0
def test_new_parent(mock_record, requested):
    mock_profile = mock.Mock(id=2, notify_new_parent=requested)
    mock_signup = mock.Mock(id=3)
    record.new_parent(mock_profile, mock_signup)

    mock_record.assert_called_with(
        mock_profile, 'new parent', triggering=requested, data={'signup-id': 3})
    def test_new_parents(self, params, recip):
        context = {}
        for student_name, parent_name, role, group_name in params['scenario']:
            ts = factories.TextSignupFactory.create(teacher=recip,
                                                    family__name=parent_name,
                                                    family__role=role)

            ts.student = factories.RelationshipFactory.create(
                from_profile=ts.family, to_profile__name=student_name).student

            if group_name is not None:
                ts.group = factories.GroupFactory.create(name=group_name)
                context['%sUrl' % group_name] = reverse(
                    'group', kwargs={'group_id': ts.group_id})

            ts.save()

            context['%sUrl' % student_name] = reverse(
                'village', kwargs={'student_id': ts.student_id})

            record.new_parent(recip, ts)

        assert base.send(recip.id)
        self.assert_multi_email(params['subject'], params['html'],
                                params['text'], context)
def test_new_parent(mock_record, requested):
    mock_profile = mock.Mock(id=2, notify_new_parent=requested)
    mock_signup = mock.Mock(id=3)
    record.new_parent(mock_profile, mock_signup)

    mock_record.assert_called_with(mock_profile,
                                   'new parent',
                                   triggering=requested,
                                   data={'signup-id': 3})
    def test_no_requested(self, params, recip):
        """If no (non-post) requested notifications, container not shown."""
        rel = factories.RelationshipFactory.create(
            from_profile=recip, to_profile__name='A Student')
        signup = factories.TextSignupFactory.create(student=rel.student)

        record.new_parent(recip, signup)

        assert base.send(recip.id)
        assert len(mail.outbox) == 1
        html_body = mail.outbox[0].alternatives[0][0]
        assert 'class="requested"' not in html_body
        assert 'class="nonrequested"' in html_body
Example #5
0
    def test_no_requested(self, params, recip):
        """If no (non-post) requested notifications, container not shown."""
        rel = factories.RelationshipFactory.create(
            from_profile=recip, to_profile__name='A Student')
        signup = factories.TextSignupFactory.create(
            student=rel.student)

        record.new_parent(recip, signup)

        assert base.send(recip.id)
        assert len(mail.outbox) == 1
        html_body = mail.outbox[0].alternatives[0][0]
        assert 'class="requested"' not in html_body
        assert 'class="nonrequested"' in html_body
Example #6
0
    def test_new_parents(self, params, recip):
        context = {}
        for student_name, parent_name, role, group_name in params['scenario']:
            ts = factories.TextSignupFactory.create(
                teacher=recip, family__name=parent_name, family__role=role)

            ts.student = factories.RelationshipFactory.create(
                from_profile=ts.family, to_profile__name=student_name).student

            if group_name is not None:
                ts.group = factories.GroupFactory.create(name=group_name)
                context['%sUrl' % group_name] = reverse(
                    'group', kwargs={'group_id': ts.group_id})

            ts.save()

            context['%sUrl' % student_name] = reverse(
                'village', kwargs={'student_id': ts.student_id})

            record.new_parent(recip, ts)

        assert base.send(recip.id)
        self.assert_multi_email(
            params['subject'], params['html'], params['text'], context)