Ejemplo n.º 1
0
def test_bulk_post(mock_record, requested):
    mock_profile = mock.Mock(id=2, notify_teacher_post=requested)
    mock_post = mock.Mock(id=3, author=mock.Mock(school_staff=True))
    record.bulk_post(mock_profile, mock_post)

    mock_record.assert_called_with(
        mock_profile,
        'bulk post',
        triggering=requested,
        data={'bulk-post-id': 3},
        )
Ejemplo n.º 2
0
def test_bulk_post(mock_record, requested):
    mock_profile = mock.Mock(id=2, notify_teacher_post=requested)
    mock_post = mock.Mock(id=3, author=mock.Mock(school_staff=True))
    record.bulk_post(mock_profile, mock_post)

    mock_record.assert_called_with(
        mock_profile,
        'bulk post',
        triggering=requested,
        data={'bulk-post-id': 3},
    )
Ejemplo n.º 3
0
    def test_bulk_posts(self, params, recip):
        context = {}
        name_map = {}
        now = datetime(2012, 1, 15, tzinfo=timezone.utc)
        for teacher_name, my_sts, other_sts, msg, ago in params['scenario']:
            if teacher_name not in name_map:
                name_map[teacher_name] = factories.ProfileFactory.create(
                    school_staff=True, name=teacher_name, role="Teacher")
            teacher = name_map[teacher_name]
            all_students = []
            for st_name in my_sts:
                if st_name not in name_map:
                    name_map[st_name] = factories.RelationshipFactory.create(
                        to_profile__name=st_name, from_profile=recip).student
                all_students.append(name_map[st_name])
            for st_name in other_sts:
                if st_name not in name_map:
                    name_map[st_name] = factories.ProfileFactory.create(
                        name=st_name)
                all_students.append(name_map[st_name])
            group = factories.GroupFactory.create(owner=teacher)
            group.students.add(*all_students)
            html_text = "html: %s" % msg
            timestamp = now - ago
            bulk_post = factories.BulkPostFactory.create(
                author=teacher,
                group=group,
                original_text=msg,
                html_text=html_text,
                timestamp=timestamp,
            )
            for student in all_students:
                context['%sUrl' % student.name] = reverse(
                    'village', kwargs={'student_id': student.id})
                factories.PostFactory.create(
                    author=teacher,
                    student=student,
                    from_bulk=bulk_post,
                    original_text=msg,
                    html_text=html_text,
                    timestamp=timestamp,
                )
            record.bulk_post(recip, bulk_post)

        assert base.send(recip.id)
        self.assert_multi_email(params['subject'], params['html'],
                                params['text'], context)
Ejemplo n.º 4
0
    def test_bulk_posts(self, params, recip):
        context = {}
        name_map = {}
        now = datetime(2012, 1, 15, tzinfo=timezone.utc)
        for teacher_name, my_sts, other_sts, msg, ago in params['scenario']:
            if teacher_name not in name_map:
                name_map[teacher_name] = factories.ProfileFactory.create(
                    school_staff=True, name=teacher_name, role="Teacher")
            teacher = name_map[teacher_name]
            all_students = []
            for st_name in my_sts:
                if st_name not in name_map:
                    name_map[st_name] = factories.RelationshipFactory.create(
                        to_profile__name=st_name, from_profile=recip).student
                all_students.append(name_map[st_name])
            for st_name in other_sts:
                if st_name not in name_map:
                    name_map[st_name] = factories.ProfileFactory.create(
                        name=st_name)
                all_students.append(name_map[st_name])
            group = factories.GroupFactory.create(owner=teacher)
            group.students.add(*all_students)
            html_text = "html: %s" % msg
            timestamp = now - ago
            bulk_post = factories.BulkPostFactory.create(
                author=teacher,
                group=group,
                original_text=msg,
                html_text=html_text,
                timestamp=timestamp,
                )
            for student in all_students:
                context['%sUrl' % student.name] = reverse(
                    'village', kwargs={'student_id': student.id})
                factories.PostFactory.create(
                    author=teacher,
                    student=student,
                    from_bulk=bulk_post,
                    original_text=msg,
                    html_text=html_text,
                    timestamp=timestamp,
                    )
            record.bulk_post(recip, bulk_post)

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