示例#1
0
    def test_email_event_attendees(self, mock_success):
        """Send email to selected event attendees."""
        user = UserFactory.create(groups=['Rep'])
        event = EventFactory.create(slug='test-event', owner=user)
        AttendanceFactory.create_batch(3, event=event)
        self.client.login(username=user.username, password='******')
        reps = event.attendees.all()
        valid_data = dict()
        for rep in reps:
            field_name = '%s %s <%s>' % (rep.first_name, rep.last_name,
                                         rep.email)
            valid_data[field_name] = 'True'

        valid_data['subject'] = 'This is the mail subject'
        valid_data['body'] = 'This is the mail subject'
        valid_data['slug'] = 'test-event'

        url = reverse('email_attendees', kwargs={'slug': 'test-event'})
        response = self.client.post(url, valid_data, follow=True)
        self.assertTemplateUsed(response, 'view_event.html')

        mock_success.assert_called_with(ANY, 'Email sent successfully.')
        eq_(len(mail.outbox), 1)

        email = mail.outbox[0]
        eq_(len(email.to), 4)
        eq_(len(email.cc), 1)
示例#2
0
    def test_email_event_attendees(self, mock_success):
        """Send email to selected event attendees."""
        user = UserFactory.create(groups=['Rep'])
        event = EventFactory.create(slug='test-event', owner=user)
        AttendanceFactory.create_batch(3, event=event)
        reps = event.attendees.all()
        valid_data = dict()
        for rep in reps:
            field_name = '%s' % rep.id
            valid_data[field_name] = 'True'

        valid_data['subject'] = 'This is the mail subject'
        valid_data['body'] = 'This is the mail subject'
        valid_data['slug'] = 'test-event'

        url = reverse('email_attendees', kwargs={'slug': event.slug})
        with self.login(user) as client:
            response = client.post(url, valid_data, follow=True)
        ok_('view_event.jinja' in [
            template.template.name for template in response.templates
            if isinstance(template, Jinja_Template)
        ])

        mock_success.assert_called_with(ANY, 'Email sent successfully.')
        eq_(len(mail.outbox), 4)

        for i in range(0, len(mail.outbox)):
            eq_(len(mail.outbox[i].cc), 1)
            eq_(len(mail.outbox[i].to), 1)
示例#3
0
    def test_email_event_attendees(self, mock_success):
        """Send email to selected event attendees."""
        user = UserFactory.create(groups=['Rep'])
        event = EventFactory.create(slug='test-event', owner=user)
        AttendanceFactory.create_batch(3, event=event)
        reps = event.attendees.all()
        valid_data = dict()
        for rep in reps:
            field_name = '%s' % rep.id
            valid_data[field_name] = 'True'

        valid_data['subject'] = 'This is the mail subject'
        valid_data['body'] = 'This is the mail subject'
        valid_data['slug'] = 'test-event'

        url = reverse('email_attendees', kwargs={'slug': event.slug})
        with self.login(user) as client:
            response = client.post(url, valid_data, follow=True)
        ok_('view_event.jinja' in [template.template.name
                                   for template in response.templates
                                   if isinstance(template, Jinja_Template)])

        mock_success.assert_called_with(ANY, 'Email sent successfully.')
        eq_(len(mail.outbox), 4)

        for i in range(0, len(mail.outbox)):
            eq_(len(mail.outbox[i].cc), 1)
            eq_(len(mail.outbox[i].to), 1)
示例#4
0
文件: test_views.py 项目: Mte90/remo
    def test_email_event_attendees(self, mock_success):
        """Send email to selected event attendees."""
        user = UserFactory.create(groups=['Rep'])
        event = EventFactory.create(slug='test-event', owner=user)
        AttendanceFactory.create_batch(3, event=event)
        self.client.login(username=user.username, password='******')
        reps = event.attendees.all()
        valid_data = dict()
        for rep in reps:
            field_name = '%s' % rep.id
            valid_data[field_name] = 'True'

        valid_data['subject'] = 'This is the mail subject'
        valid_data['body'] = 'This is the mail subject'
        valid_data['slug'] = 'test-event'

        url = reverse('email_attendees', kwargs={'slug': event.slug})
        response = self.client.post(url, valid_data, follow=True)
        self.assertTemplateUsed(response, 'view_event.html')

        mock_success.assert_called_with(ANY, 'Email sent successfully.')
        eq_(len(mail.outbox), 4)

        for i in range(0, len(mail.outbox)):
            eq_(len(mail.outbox[i].cc), 1)
            eq_(len(mail.outbox[i].to), 1)
示例#5
0
 def test_unsubscribe_from_event_subscribed(self, mock_success):
     """Test unsubscribe from event subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create()
     AttendanceFactory.create(user=user, event=event)
     with self.login(user) as client:
         response = client.post(reverse('events_unsubscribe_from_event',
                                        kwargs={'slug': event.slug}),
                                follow=True)
     self.assertJinja2TemplateUsed(response, 'view_event.jinja')
     msg = 'You have unsubscribed from this event.'
     mock_success.assert_called_with(ANY, msg)
示例#6
0
 def test_subscription_management_subscribed(self, mock_warning):
     """ Test subscribe already subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create()
     AttendanceFactory.create(user=user, event=event)
     with self.login(user) as client:
         response = client.post(reverse('events_subscribe_to_event',
                                        kwargs={'slug': event.slug}),
                                follow=True)
     self.assertJinja2TemplateUsed(response, 'view_event.jinja')
     msg = 'You are already subscribed to this event.'
     mock_warning.assert_called_with(ANY, msg)
示例#7
0
    def test_attendance_list_sorting(self):
        """Test sorting of event attendance list."""
        e = EventFactory.create(start=START_DT, end=self.single_day_end)
        AttendanceFactory.create_batch(2, event=e)

        sorted_list = get_sorted_attendance_list(e)
        eq_(sorted_list[0], e.owner, 'Owner is not first.')

        copy_list = sorted_list[1:]
        sorted(copy_list, key=lambda x: '%s %s' % (x.last_name, x.first_name))

        eq_(copy_list, sorted_list[1:], 'List is not properly sorted.')
示例#8
0
 def test_unsubscribe_from_event_subscribed(self, mock_success):
     """Test unsubscribe from event subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create()
     AttendanceFactory.create(user=user, event=event)
     with self.login(user) as client:
         response = client.post(reverse('events_unsubscribe_from_event',
                                        kwargs={'slug': event.slug}),
                                follow=True)
     self.assertJinja2TemplateUsed(response, 'view_event.jinja')
     msg = 'You have unsubscribed from this event.'
     mock_success.assert_called_with(ANY, msg)
示例#9
0
 def test_subscription_management_subscribed(self, mock_warning):
     """ Test subscribe already subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create()
     AttendanceFactory.create(user=user, event=event)
     with self.login(user) as client:
         response = client.post(reverse('events_subscribe_to_event',
                                        kwargs={'slug': event.slug}),
                                follow=True)
     self.assertJinja2TemplateUsed(response, 'view_event.jinja')
     msg = 'You are already subscribed to this event.'
     mock_warning.assert_called_with(ANY, msg)
示例#10
0
    def test_attendance_list_sorting(self):
        """Test sorting of event attendance list."""
        e = EventFactory.create(start=START_DT, end=self.single_day_end)
        AttendanceFactory.create_batch(2, event=e)

        sorted_list = get_sorted_attendance_list(e)
        eq_(sorted_list[0], e.owner, 'Owner is not first.')

        copy_list = sorted_list[1:]
        sorted(copy_list, key=lambda x: '%s %s' % (x.last_name, x.first_name))

        eq_(copy_list, sorted_list[1:],
            'List is not properly sorted.')
示例#11
0
 def test_unsubscribe_from_event_subscribed(self, mock_success):
     """Test unsubscribe from event subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create(slug='test-event')
     AttendanceFactory.create(user=user, event=event)
     self.client.login(username=user.username, password='******')
     response = self.client.post(reverse('events_unsubscribe_from_event',
                                         kwargs={'slug': 'test-event'}),
                                 follow=True)
     self.assertTemplateUsed(response, 'view_event.html',
                             ('Rep user is not returned to '
                              'event page after unsubscribing.'))
     msg = 'You have unsubscribed from this event.'
     mock_success.assert_called_with(ANY, msg)
示例#12
0
文件: test_views.py 项目: Mte90/remo
 def test_unsubscribe_from_event_subscribed(self, mock_success):
     """Test unsubscribe from event subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create()
     AttendanceFactory.create(user=user, event=event)
     self.client.login(username=user.username, password='******')
     response = self.client.post(reverse('events_unsubscribe_from_event',
                                         kwargs={'slug': event.slug}),
                                 follow=True)
     self.assertTemplateUsed(response, 'view_event.html',
                             ('Rep user is not returned to '
                              'event page after unsubscribing.'))
     msg = 'You have unsubscribed from this event.'
     mock_success.assert_called_with(ANY, msg)
示例#13
0
文件: test_views.py 项目: Mte90/remo
 def test_subscription_management_subscribed(self, mock_warning):
     """ Test subscribe already subscribed user."""
     user = UserFactory.create(groups=['Rep'])
     event = EventFactory.create()
     AttendanceFactory.create(user=user, event=event)
     self.client.login(username=user.username, password='******')
     response = self.client.post(reverse('events_subscribe_to_event',
                                         kwargs={'slug': event.slug}),
                                 follow=True)
     self.assertTemplateUsed(response, 'view_event.html',
                             ('Rep user is not returned to '
                              'event page after subscribing.'))
     msg = 'You are already subscribed to this event.'
     mock_warning.assert_called_with(ANY, msg)
示例#14
0
 def test_delete_passive_event_attendance_report(self):
     """Test delete passive report after attendance delete."""
     event = EventFactory.create()
     user = UserFactory.create(groups=['Rep', 'Mentor'],
                               userprofile__initial_council=True)
     attendance = AttendanceFactory.create(event=event, user=user)
     ok_(NGReport.objects.filter(event=event, user=user).exists())
     attendance.delete()
     ok_(not NGReport.objects.filter(event=event, user=user).exists())
示例#15
0
    def test_create_passive_event_attendance_report(self):
        """Test creating a passive report after attending an event."""
        event = EventFactory.create()
        user = UserFactory.create(groups=['Rep', 'Mentor'],
                                  userprofile__initial_council=True)
        AttendanceFactory.create(event=event, user=user)
        report = NGReport.objects.get(event=event, user=user)

        eq_(report.mentor, user.userprofile.mentor)
        eq_(report.activity.name, EVENT_ATTENDANCE_ACTIVITY)
        eq_(report.latitude, event.lat)
        eq_(report.longitude, event.lon)
        eq_(report.location, event.venue)
        eq_(report.is_passive, True)
        eq_(report.link, get_event_link(event))
        eq_(report.activity_description, event.description)
        self.assertQuerysetEqual(report.functional_areas.all(),
                                 [e.name for e in event.categories.all()],
                                 lambda x: x.name)
示例#16
0
 def test_delete_attendance(self):
     """Test delete passive report after attendance delete."""
     activity = Activity.objects.get(name=ACTIVITY_EVENT_ATTEND)
     event = EventFactory.create()
     user = UserFactory.create(groups=['Rep', 'Mentor'],
                               userprofile__initial_council=True)
     attendance = AttendanceFactory.create(event=event, user=user)
     ok_(NGReport.objects.filter(event=event, user=user).exists())
     attendance.delete()
     query = NGReport.objects.filter(event=event, user=user,
                                     activity=activity)
     ok_(not query.exists())
示例#17
0
 def test_delete_attendance(self):
     """Test delete passive report after attendance delete."""
     activity = Activity.objects.get(name=ACTIVITY_EVENT_ATTEND)
     event = EventFactory.create()
     user = UserFactory.create(groups=['Rep', 'Mentor'],
                               userprofile__initial_council=True)
     attendance = AttendanceFactory.create(event=event, user=user)
     ok_(NGReport.objects.filter(event=event, user=user).exists())
     attendance.delete()
     query = NGReport.objects.filter(event=event,
                                     user=user,
                                     activity=activity)
     ok_(not query.exists())
示例#18
0
    def test_attendee(self):
        """Test creating a passive report after attending an event."""
        activity = Activity.objects.get(name=ACTIVITY_EVENT_ATTEND)
        event = EventFactory.create()
        user = UserFactory.create(groups=['Rep', 'Mentor'],
                                  userprofile__initial_council=True)
        AttendanceFactory.create(event=event, user=user)
        report = NGReport.objects.get(event=event,
                                      user=user,
                                      activity=activity)

        location = '%s, %s, %s' % (event.city, event.region, event.country)
        eq_(report.mentor, user.userprofile.mentor)
        eq_(report.activity.name, ACTIVITY_EVENT_ATTEND)
        eq_(report.latitude, event.lat)
        eq_(report.longitude, event.lon)
        eq_(report.location, location)
        eq_(report.is_passive, True)
        eq_(report.link, get_event_link(event))
        eq_(report.activity_description, event.description)
        self.assertQuerysetEqual(report.functional_areas.all(),
                                 [e.name for e in event.categories.all()],
                                 lambda x: x.name)