def test_quarter(self, mock_api_now, mock_utils_now): now_return_value = datetime(2015, 3, 1) mock_api_now.return_value = now_return_value mock_utils_now.return_value = now_return_value # Previous quarter start = datetime(2014, 12, 5) end = datetime(2014, 12, 6) EventFactory.create_batch(2, start=start, end=end) # This quarter start = datetime(2015, 1, 5) end = datetime(2015, 1, 6) EventFactory.create(start=start, end=end) # Next quarter start = datetime(2015, 5, 3) end = datetime(2015, 5, 5) EventFactory.create(start=start, end=end) request = self.factory.get(self.url) request.query_params = dict() response = EventsKPIView().get(request) eq_(response.data['quarter_total'], 1) eq_(response.data['quarter_growth_percentage'], -(3 - 2) * 100 / 2.0)
def test_export_event_to_ical(self): """Test ical export.""" EventFactory.create(slug='test-event') response = self.client.get( reverse('events_icalendar_event', kwargs={'slug': 'test-event'})) self.assertTemplateUsed(response, 'multi_event_ical_template.ics') self.failUnless(response['Content-Type'].startswith('text/calendar'))
def test_current_week(self, mock_api_now, mock_utils_now): now_return_value = datetime(2015, 3, 1) mock_api_now.return_value = now_return_value mock_utils_now.return_value = now_return_value # Current week start = datetime(2015, 2, 25) end = datetime(2015, 2, 26) EventFactory.create(start=start, end=end) # Previous week start = datetime(2015, 2, 18) end = datetime(2015, 2, 19) EventFactory.create_batch(2, start=start, end=end) # Next week start = datetime(2015, 3, 4) end = datetime(2015, 3, 5) EventFactory.create(start=start, end=end) request = self.factory.get(self.url) request.query_params = dict() response = EventsKPIView().get(request) eq_(response.data['week_total'], 1) eq_(response.data['week_growth_percentage'], (1 - 2) * 100 / 2.0)
def test_unsubscribe_from_event_unauth(self): """Unsubscribe from event anonymous user.""" EventFactory.create(slug='test-event') self.client.post(reverse('events_unsubscribe_from_event', kwargs={'slug': 'test-event'}), follow=True)
def test_export_event_to_ical(self): """Test ical export.""" EventFactory.create(slug='test-event') response = self.client.get(reverse('events_icalendar_event', kwargs={'slug': 'test-event'})) self.assertTemplateUsed(response, 'multi_event_ical_template.ics') self.failUnless(response['Content-Type'].startswith('text/calendar'))
def test_is_multiday(self): """Test is_multiday filter.""" e = EventFactory.create() ok_(is_multiday(e.start, e.end), 'Multiday event validates to False') e = EventFactory.create(start=START_DT, end=self.single_day_end) ok_(not is_multiday(e.start, e.end), 'Single day event validates to True')
def test_post_comment_on_event_unauthed(self, mock_error): """Test post comment on event unauthorized.""" comment = 'This is a new comment' EventFactory.create(slug='test-event') response = self.client.post(self.event_url, {'comment': comment}, follow=True) self.assertTemplateUsed(response, 'main.html') mock_error.assert_called_with(ANY, 'Permission Denied')
def test_end_date_in_the_future(self): owner = UserFactory.create() EventFactory.create(start=self.start, end=self.end + timedelta(days=2), owner=owner) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_end_date_in_the_past(self): owner = UserFactory.create() EventFactory.create(end=now() - timedelta(days=3), owner=owner) with patch("remo.events.tasks.send_remo_mail") as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_end_date_in_the_past(self): owner = UserFactory.create() EventFactory.create(end=now() - timedelta(days=3), owner=owner) with patch('remo.events.tasks.send_remo_mail') as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_get_edit_event_admin(self, mock_success): """Test get event edit page with admin permissions""" user = UserFactory.create(groups=['Admin']) EventFactory.create(slug='test-event') self.client.login(username=user.username, password='******') response = self.client.get(self.event_edit_url, follow=True) eq_(response.request['PATH_INFO'], self.event_edit_url) ok_(not response.context['creating']) ok_(response.context['event_form'].editable_owner) eq_(response.context['event'].slug, 'test-event') self.assertTemplateUsed('edit_event.html')
def test_weeks(self, mock_api_now, mock_utils_now): now_return_value = datetime(2015, 3, 1) mock_api_now.return_value = now_return_value mock_utils_now.return_value = now_return_value # Current week start = datetime(2015, 2, 25) end = datetime(2015, 2, 26) EventFactory.create_batch(3, start=start, end=end) # Week-1 start = datetime(2015, 2, 18) end = datetime(2015, 2, 19) EventFactory.create_batch(2, start=start, end=end) # Week-2 start = datetime(2015, 2, 11) end = datetime(2015, 2, 12) EventFactory.create_batch(4, start=start, end=end) # Week-3 start = datetime(2015, 2, 4) end = datetime(2015, 2, 5) EventFactory.create(start=start, end=end) # Next week start = datetime(2015, 3, 4) end = datetime(2015, 3, 5) EventFactory.create(start=start, end=end) request = self.factory.get(self.url) request.query_params = {'weeks': 4} response = EventsKPIView().get(request) eq_(response.data['week_total'], 3) eq_(response.data['week_growth_percentage'], (3 - 2) * 100 / 2.0) total_per_week = [{ 'week': 1, 'events': 1 }, { 'week': 2, 'events': 4 }, { 'week': 3, 'events': 2 }, { 'week': 4, 'events': 3 }] for entry in response.data['total_per_week']: ok_(entry in total_per_week) eq_(len(response.data['total_per_week']), 4)
def test_edit_owner(self): """Test change event ownership.""" owner = UserFactory.create() EventFactory.create(owner=owner) report = NGReport.objects.get(user=owner) new_owner = UserFactory.create() report.event.owner = new_owner report.event.save() report = NGReport.objects.get(pk=report.id) eq_(report.user, new_owner) eq_(report.mentor, new_owner.userprofile.mentor)
def test_with_existing_action_item(self): owner = UserFactory.create() EventFactory.create(start=self.start, end=self.end, owner=owner) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_subscription_management_rep(self, mock_info): """ Subscribe rep to event.""" user = UserFactory.create(groups=['Rep']) EventFactory.create(slug='test-event') self.client.login(username=user.username, password='******') response = self.client.post(reverse('events_subscribe_to_event', kwargs={'slug': 'test-event'}), follow=True) self.assertTemplateUsed(response, 'view_event.html', ('Rep user is not returned to ' 'event page after subscribing.')) ok_(mock_info.called, 'messages.info() was not called')
def test_edit_event_page_no_delete_perms(self, mock_perm): """Test view edit event page without delete permissions.""" user = UserFactory.create(groups=['Admin']) EventFactory.create(slug='test-event') mock_perm.side_effect = [True, False] self.client.login(username=user.username, password='******') response = self.client.get(self.event_edit_url, follow=True) eq_(response.request['PATH_INFO'], self.event_edit_url) ok_(not response.context['creating']) ok_(response.context['event_form'].editable_owner) eq_(response.context['event'].slug, 'test-event') ok_(not response.context['can_delete_event'])
def test_multi_event_ical_export_search(self): """Test multiple past event ical export.""" EventFactory.create(name='Test event') # Test 'search' query term = 'Test event' search = 'custom/search/%s' % term response = self.client.get(reverse('multiple_event_ical', kwargs={'period': search}), follow=True) self.failUnless(response['Content-Type'].startswith('text/calendar')) eq_(len(response.context['events']), 1)
def test_post_event_metrics(self): model = ContentType.objects.get_for_model(Event) items = ActionItem.objects.filter(content_type=model) ok_(not items.exists()) start = now() - timedelta(days=4) end = now() - timedelta(days=1) user = UserFactory.create(groups=['Rep']) EventFactory.create(owner=user, start=start, end=end) notify_event_owners_to_input_metrics() items = ActionItem.objects.filter(content_type=model) eq_(items.count(), 1)
def test_with_existing_action_item(self): owner = UserFactory.create() end = now() - timedelta(days=1) EventFactory.create(end=end, owner=owner) with patch('remo.events.tasks.send_remo_mail') as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch('remo.events.tasks.send_remo_mail') as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_with_existing_action_item(self): owner = UserFactory.create() end = now() - timedelta(days=1) EventFactory.create(end=end, owner=owner) with patch("remo.events.tasks.send_remo_mail") as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch("remo.events.tasks.send_remo_mail") as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_unsubscribe_from_event_unsubscribed(self, mock_warning): """Test unsubscribe from event without subscription.""" user = UserFactory.create(groups=['Rep']) EventFactory.create(slug='test-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 are not subscribed to this event.' mock_warning.assert_called_with(ANY, msg)
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)
def test_delete_event_unauthorized(self): """Test delete event unauthorized.""" event = EventFactory.create() self.client.get(reverse('events_delete_event', kwargs={'slug': event.slug}), follow=True) ok_(Event.objects.filter(pk=event.id).exists())
def test_get_remo_url(self): event = EventFactory.create() url = '/api/beta/events/%s' % event.id request = RequestFactory().get(url) data = EventDetailedSerializer(event, context={'request': request}).data ok_(event.get_absolute_url() in data['remo_url'])
def test_base(self): event = EventFactory.create() url = '/api/remo/v1/events/%s' % event.id request = RequestFactory().get(url) serializer = EventSerializer(event, context={'request': request}) eq_(serializer.data['name'], event.name) ok_(serializer.data['_url'])
def test_edit_event(self): """Edit event with inactive categories.""" start_form = { 'start_form_0_month': 1, 'start_form_0_day': 25, 'start_form_0_year': 2014, 'start_form_1_hour': 4, 'start_form_1_minute': 1} end_form = { 'end_form_0_month': 1, 'end_form_0_day': 25, 'end_form_0_year': 2015, 'end_form_1_hour': 4, 'end_form_1_minute': 1} owner = UserFactory.create(groups=['Mentor']) active_areas = FunctionalAreaFactory.create_batch(2) inactive_areas = FunctionalAreaFactory.create_batch(2, active=False) event = EventFactory.create(owner=owner, categories=inactive_areas) data = model_to_dict(event) data['categories'] = [x.id for x in active_areas + inactive_areas] data.update(start_form) data.update(end_form) form = EventForm(data=data, editable_owner=False, instance=event) ok_(form.is_valid()) result = form.save() for area in active_areas + inactive_areas: ok_(area in result.categories.all())
def test_base(self): user = UserFactory.create() categories = [FunctionalAreaFactory.create()] initiative = CampaignFactory.create() event = EventFactory.create(categories=categories, owner=user, campaign=initiative) url = '/api/beta/events/%s' % event.id request = RequestFactory().get(url) data = EventDetailedSerializer(event, context={'request': request}).data serialized_start = parser.parse(data['start']) serialized_end = parser.parse(data['end']) eq_(data['name'], event.name) eq_(data['description'], event.description) eq_(serialized_start.date(), event.start.date()) eq_(serialized_start.time(), event.start.time()) eq_(serialized_end.date(), event.end.date()) eq_(serialized_end.time(), event.end.time()) eq_(data['timezone'], event.timezone) eq_(data['city'], event.city) eq_(data['region'], event.region) eq_(data['country'], event.country) eq_(data['lat'], event.lat) eq_(data['lon'], event.lon) eq_(data['external_link'], event.external_link) eq_(data['estimated_attendance'], event.estimated_attendance) eq_(data['planning_pad_url'], event.planning_pad_url) eq_(data['hashtag'], event.hashtag) eq_(data['owner']['first_name'], user.first_name) eq_(data['owner']['last_name'], user.last_name) eq_(data['owner']['display_name'], user.userprofile.display_name) ok_(data['owner']['_url']) eq_(data['categories'][0]['name'], categories[0].name) eq_(data['initiative'], initiative.name)
def test_base(self): user = UserFactory.create() categories = [FunctionalAreaFactory.create()] initiative = CampaignFactory.create() event = EventFactory.create(categories=categories, owner=user, campaign=initiative) url = '/api/remo/v1/events/%s' % event.id request = RequestFactory().get(url) data = EventDetailedSerializer(event, context={ 'request': request }).data eq_(data['name'], event.name) eq_(data['description'], event.description) eq_(data['start'], event.start) eq_(data['end'], event.end) eq_(data['timezone'], event.timezone) eq_(data['city'], event.city) eq_(data['region'], event.region) eq_(data['country'], event.country) eq_(data['lat'], event.lat) eq_(data['lon'], event.lon) eq_(data['external_link'], event.external_link) eq_(data['estimated_attendance'], event.estimated_attendance) eq_(data['planning_pad_url'], event.planning_pad_url) eq_(data['hashtag'], event.hashtag) eq_(data['owner']['first_name'], user.first_name) eq_(data['owner']['last_name'], user.last_name) eq_(data['owner']['display_name'], user.userprofile.display_name) ok_(data['owner']['_url']) eq_(data['categories'][0]['name'], categories[0].name) eq_(data['initiative'], initiative.name)
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)
def test_post_comment_on_event_rep(self, mock_success): """Test post comment on event as rep.""" # Test authenticated user event = EventFactory.create() kwargs = { 'groups': ['Rep'], 'userprofile__receive_email_on_add_event_comment': True } user = UserFactory.create(**kwargs) comment = 'This is a new comment' with self.login(user) as client: response = client.post(event.get_absolute_url(), {'comment': comment}, follow=True) comment = event.eventcomment_set.get(user=user) ok_('view_event.jinja' in [ template.template.name for template in response.templates if isinstance(template, Jinja_Template) ]) mock_success.assert_called_with(ANY, 'Comment saved') eq_(comment.comment, 'This is a new comment') eq_(len(mail.outbox), 1)
def test_passive_report_save(self): """Test that a passive report is created on form save()""" start_form = { 'start_form_0_month': 1, 'start_form_0_day': 25, 'start_form_0_year': 2013, 'start_form_1_hour': 4, 'start_form_1_minute': 1} end_form = { 'end_form_0_month': 1, 'end_form_0_day': 26, 'end_form_0_year': 2013, 'end_form_1_hour': 4, 'end_form_1_minute': 1} owner = UserFactory.create(groups=['Rep', 'Mentor']) areas = FunctionalAreaFactory.create_batch(2) event = EventFactory.create(owner=owner, categories=areas) data = model_to_dict(event) data['categories'] = [x.id for x in areas] data.update(start_form) data.update(end_form) form = PostEventForm(data=data, editable_owner=False, instance=event) activity = Activity.objects.get(name=ACTIVITY_POST_EVENT_METRICS) reports = NGReport.objects.filter(user=owner, activity=activity) ok_(not reports.exists()) ok_(form.is_valid()) form.save() reports = NGReport.objects.filter(user=owner, activity=activity) ok_(reports.count(), 1)
def test_base(self): event = EventFactory.create() url = '/api/beta/events/%s' % event.id request = RequestFactory().get(url) serializer = EventSerializer(event, context={'request': request}) eq_(serializer.data['name'], event.name) ok_(serializer.data['_url'])
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)
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)
def test_base(self): mentor = UserFactory.create() user = UserFactory.create(userprofile__mentor=mentor) event = EventFactory.create() functional_areas = [FunctionalAreaFactory.create()] campaign = CampaignFactory.create() activity = ActivityFactory.create() report = NGReportFactory.create( functional_areas=functional_areas, mentor=mentor, campaign=campaign, user=user, event=event, activity=activity) url = '/api/beta/activities/%s' % report.id request = RequestFactory().get(url) data = ActivitiesDetailedSerializer(report, context={'request': request}).data eq_(data['user']['first_name'], user.first_name) eq_(data['user']['last_name'], user.last_name) eq_(data['user']['display_name'], user.userprofile.display_name) ok_(data['user']['_url']) eq_(data['activity'], activity.name) eq_(data['initiative'], campaign.name) eq_(data['functional_areas'][0]['name'], functional_areas[0].name) eq_(data['activity_description'], report.activity_description) eq_(data['location'], report.location) eq_(data['latitude'], float(report.latitude)) eq_(data['longitude'], float(report.longitude)) eq_(data['report_date'], report.report_date.strftime('%Y-%m-%d')) eq_(data['link'], report.link) eq_(data['link_description'], report.link_description) eq_(data['mentor']['first_name'], mentor.first_name) eq_(data['mentor']['last_name'], mentor.last_name) eq_(data['mentor']['display_name'], mentor.userprofile.display_name) ok_(data['mentor']['_url']) eq_(data['passive_report'], report.is_passive) eq_(data['event']['name'], event.name) ok_(data['event']['_url'])
def test_edit_event(self): """Edit event with inactive categories.""" start_form = { 'start_form_0_month': 1, 'start_form_0_day': 25, 'start_form_0_year': 2014, 'start_form_1_hour': 4, 'start_form_1_minute': 1} end_form = { 'end_form_0_month': 1, 'end_form_0_day': 25, 'end_form_0_year': 2015, 'end_form_1_hour': 4, 'end_form_1_minute': 1} owner = UserFactory.create(groups=['Mentor']) functional_area = [FunctionalAreaFactory.create()] campaign = [CampaignFactory.create()] event = EventFactory.create(owner=owner, categories=functional_area) data = model_to_dict(event) data['categories'] = functional_area[0].id data['campaign'] = campaign[0].id data.update(start_form) data.update(end_form) form = EventForm(data=data, editable_owner=False, instance=event) ok_(form.is_valid()) result = form.save() ok_(functional_area[0] in result.categories.all())
def test_weeks(self, mock_api_now, mock_utils_now): now_return_value = datetime(2015, 3, 1) mock_api_now.return_value = now_return_value mock_utils_now.return_value = now_return_value # Current week start = datetime(2015, 2, 25) end = datetime(2015, 2, 26) EventFactory.create_batch(3, start=start, end=end) # Week-1 start = datetime(2015, 2, 18) end = datetime(2015, 2, 19) EventFactory.create_batch(2, start=start, end=end) # Week-2 start = datetime(2015, 2, 11) end = datetime(2015, 2, 12) EventFactory.create_batch(4, start=start, end=end) # Week-3 start = datetime(2015, 2, 4) end = datetime(2015, 2, 5) EventFactory.create(start=start, end=end) # Next week start = datetime(2015, 3, 4) end = datetime(2015, 3, 5) EventFactory.create(start=start, end=end) request = self.factory.get(self.url) request.query_params = {'weeks': 4} response = EventsKPIView().get(request) eq_(response.data['week_total'], 3) eq_(response.data['week_growth_percentage'], (3 - 2) * 100 / 2.0) total_per_week = [ {'week': 1, 'events': 1}, {'week': 2, 'events': 4}, {'week': 3, 'events': 2}, {'week': 4, 'events': 3} ] for entry in response.data['total_per_week']: ok_(entry in total_per_week) eq_(len(response.data['total_per_week']), 4)
def test_contribute_link(self): """Test /contribute link generation.""" e = EventFactory.create(start=START_DT, end=self.single_day_end) url = (settings.CONTRIBUTE_URL % {'callbackurl': (settings.SITE_URL + reverse('events_count_converted_visitors', kwargs={'slug': e.slug}))}) eq_(get_contribute_link(e), url)
def test_get_remo_url(self): event = EventFactory.create() url = '/api/remo/v1/events/%s' % event.id request = RequestFactory().get(url) data = EventDetailedSerializer(event, context={ 'request': request }).data ok_(event.get_absolute_url() in data['remo_url'])
def test_converted_visitors(self): """Test converted visitors counter.""" event = EventFactory.create(slug='test-event') converted_visitors = event.converted_visitors + 1 self.client.post(reverse('events_count_converted_visitors', kwargs={'slug': 'test-event'}), follow=True) event = Event.objects.get(slug='test-event') eq_(event.converted_visitors, converted_visitors)
def test_post_comment_on_event_unauthed(self, mock_error): """Test post comment on event unauthorized.""" comment = 'This is a new comment' event = EventFactory.create() response = self.client.post(event.get_absolute_url(), {'comment': comment}, follow=True) self.assertJinja2TemplateUsed(response, 'main.jinja') mock_error.assert_called_with(ANY, 'Permission Denied')
def test_converted_visitors(self): """Test converted visitors counter.""" event = EventFactory.create() converted_visitors = event.converted_visitors + 1 self.client.post(reverse('events_count_converted_visitors', kwargs={'slug': event.slug}), follow=True) event = Event.objects.get(slug=event.slug) eq_(event.converted_visitors, converted_visitors)
def test_contribute_link(self): """Test /contribute link generation.""" e = EventFactory.create(start=START_DT, end=self.single_day_end) url = (settings.CONTRIBUTE_URL % { 'callbackurl': (settings.SITE_URL + reverse('events_count_converted_visitors', kwargs={'slug': e.slug})) }) eq_(get_contribute_link(e), url)
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())