예제 #1
0
def test_post(mock_record, requested, from_teacher):
    pref = 'notify_%s' % ('teacher_post' if from_teacher else 'parent_text')
    mock_profile = mock.Mock(id=2, **{pref: requested})
    mock_post = mock.Mock(id=3, author=mock.Mock(school_staff=from_teacher))
    record.post(mock_profile, mock_post)

    mock_record.assert_called_with(
        mock_profile, 'post', triggering=requested, data={'post-id': 3})
예제 #2
0
def test_post(mock_record, requested, from_teacher):
    pref = 'notify_%s' % ('teacher_post' if from_teacher else 'parent_text')
    mock_profile = mock.Mock(id=2, **{pref: requested})
    mock_post = mock.Mock(id=3, author=mock.Mock(school_staff=from_teacher))
    record.post(mock_profile, mock_post)

    mock_record.assert_called_with(mock_profile,
                                   'post',
                                   triggering=requested,
                                   data={'post-id': 3})
예제 #3
0
    def test_posts(self, params, recip):
        context = {}
        name_map = {}
        rels = {}
        now = datetime(2012, 1, 15, tzinfo=timezone.utc)
        for st_name, author_name, role, text, ago, new in params['scenario']:
            if st_name not in name_map:
                name_map[st_name] = factories.RelationshipFactory.create(
                    from_profile=recip, to_profile__name=st_name).student
                context['%sUrl' % st_name] = reverse(
                    'village', kwargs={'student_id': name_map[st_name].id})
            if author_name not in name_map:
                name_map[author_name] = factories.ProfileFactory.create(
                    name=author_name, school_staff=False)
            student = name_map[st_name]
            author = name_map[author_name]
            if (student, author) not in rels:
                rel = factories.RelationshipFactory.create(from_profile=author,
                                                           to_profile=student,
                                                           description=role)
                rels[(student, author)] = rel
            else:
                rel = rels[(student, author)]
            post = factories.PostFactory.create(
                author=author,
                student=student,
                relationship=rel,
                original_text=text,
                html_text='html: %s' % text,
                timestamp=now - ago,
            )
            if new:
                record.post(recip, post)

        assert base.send(recip.id)
        self.assert_multi_email(params['subject'], params['html'],
                                params['text'], context)
예제 #4
0
    def test_posts(self, params, recip):
        context = {}
        name_map = {}
        rels = {}
        now = datetime(2012, 1, 15, tzinfo=timezone.utc)
        for st_name, author_name, role, text, ago, new in params['scenario']:
            if st_name not in name_map:
                name_map[st_name] = factories.RelationshipFactory.create(
                    from_profile=recip, to_profile__name=st_name).student
                context['%sUrl' % st_name] = reverse(
                    'village', kwargs={'student_id': name_map[st_name].id})
            if author_name not in name_map:
                name_map[author_name] = factories.ProfileFactory.create(
                    name=author_name, school_staff=False)
            student = name_map[st_name]
            author = name_map[author_name]
            if (student, author) not in rels:
                rel = factories.RelationshipFactory.create(
                    from_profile=author, to_profile=student, description=role)
                rels[(student, author)] = rel
            else:
                rel = rels[(student, author)]
            post = factories.PostFactory.create(
                author=author,
                student=student,
                relationship=rel,
                original_text=text,
                html_text='html: %s' % text,
                timestamp=now - ago,
                )
            if new:
                record.post(recip, post)

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