示例#1
0
    def test_email_about_suggested_event_comment(self):
        # first we need to add a user
        zandr = User.objects.create(username="******", email="*****@*****.**")
        group, _ = Group.objects.get_or_create(name=settings.NOTIFICATIONS_GROUP_NAME)
        zandr.groups.add(group)

        user, = User.objects.all()[:1]
        now = timezone.now()
        tomorrow = now + datetime.timedelta(days=1)
        location = Location.objects.get(id=1)

        suggested_event = SuggestedEvent.objects.create(
            user=user,
            title="TITLE",
            slug="SLUG",
            short_description="SHORT DESCRIPTION",
            description="DESCRIPTION",
            start_time=tomorrow,
            location=location,
            placeholder_img=self.placeholder,
            privacy=Event.PRIVACY_CONTRIBUTORS,
            first_submitted=now,
            submitted=now,
        )
        comment = SuggestedEventComment.objects.create(comment="Bla bla", user=user, suggested_event=suggested_event)
        request = RequestFactory().get("/")
        # bob = User.objects.create(email='*****@*****.**')
        sending.email_about_suggested_event_comment(comment, request)
        email_sent = mail.outbox[-1]
        ok_(email_sent.alternatives)
        ok_(zandr.email in email_sent.recipients())
        ok_("TITLE" in email_sent.subject)
        summary_url = reverse("suggest:summary", args=(suggested_event.pk,))
        ok_(summary_url in email_sent.body)
示例#2
0
    def test_email_about_suggested_event_comment(self):
        # first we need to add two users
        zandr = User.objects.create(
            username='******',
            email='*****@*****.**'
        )
        permission = Permission.objects.get(codename='add_event')
        group = Group.objects.get(name='testapprover')
        group.permissions.add(permission)
        zandr.groups.add(group)

        richard = User.objects.create(
            username='******',
            email='*****@*****.**',
            is_staff=True,
            is_superuser=True
        )

        user, = User.objects.all()[:1]
        now = datetime.datetime.utcnow().replace(tzinfo=utc)
        tomorrow = now + datetime.timedelta(days=1)
        location = Location.objects.get(id=1)
        category = Category.objects.create(name='CATEGORY')

        suggested_event = SuggestedEvent.objects.create(
            user=user,
            title='TITLE',
            slug='SLUG',
            short_description='SHORT DESCRIPTION',
            description='DESCRIPTION',
            start_time=tomorrow,
            location=location,
            category=category,
            placeholder_img=self.placeholder,
            privacy=Event.PRIVACY_CONTRIBUTORS,
            first_submitted=now,
            submitted=now
        )
        comment = SuggestedEventComment.objects.create(
            comment="Bla bla",
            user=user,
            suggested_event=suggested_event
        )
        request = RequestFactory().get('/')
        # bob = User.objects.create(email='*****@*****.**')
        sending.email_about_suggested_event_comment(comment, request)
        email_sent = mail.outbox[-1]
        ok_(email_sent.alternatives)
        ok_(richard.email in email_sent.recipients())
        ok_(zandr.email in email_sent.recipients())
        ok_('TITLE' in email_sent.subject)
        summary_url = reverse('suggest:summary', args=(suggested_event.pk,))
        ok_(summary_url in email_sent.body)
示例#3
0
    def test_email_about_suggested_event_comment(self):
        # first we need to add a user
        zandr = User.objects.create(username='******',
                                    email='*****@*****.**')
        group, _ = Group.objects.get_or_create(
            name=settings.NOTIFICATIONS_GROUP_NAME)
        zandr.groups.add(group)

        user, = User.objects.all()[:1]
        now = timezone.now()
        tomorrow = now + datetime.timedelta(days=1)
        location = Location.objects.get(id=1)

        suggested_event = SuggestedEvent.objects.create(
            user=user,
            title='TITLE',
            slug='SLUG',
            short_description='SHORT DESCRIPTION',
            description='DESCRIPTION',
            start_time=tomorrow,
            location=location,
            placeholder_img=self.placeholder,
            privacy=Event.PRIVACY_CONTRIBUTORS,
            first_submitted=now,
            submitted=now)
        comment = SuggestedEventComment.objects.create(
            comment="Bla bla", user=user, suggested_event=suggested_event)
        request = RequestFactory().get('/')
        # bob = User.objects.create(email='*****@*****.**')
        sending.email_about_suggested_event_comment(comment, request)
        email_sent = mail.outbox[-1]
        ok_(email_sent.alternatives)
        ok_(zandr.email in email_sent.recipients())
        ok_('TITLE' in email_sent.subject)
        summary_url = reverse('suggest:summary', args=(suggested_event.pk, ))
        ok_(summary_url in email_sent.body)