Example #1
0
 def test_post_delete_event_comment_unauth(self):
     """Test unauthorized delete event comment."""
     event = EventFactory.create(slug='test-event')
     user = UserFactory.create(groups=['Rep'])
     comment = EventCommentFactory.create(event=event, user=user)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': 'test-event',
                                      'pk': comment.id})
     self.client.post(comment_delete, {'comment': comment}, follow=True)
     ok_(EventComment.objects.filter(pk=comment.id).exists())
Example #2
0
 def test_post_delete_event_comment_unauth(self):
     """Test unauthorized delete event comment."""
     event = EventFactory.create(slug='test-event')
     user = UserFactory.create(groups=['Rep'])
     comment = EventCommentFactory.create(event=event, user=user)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': event.slug,
                                      'pk': comment.id})
     self.client.post(comment_delete, {'comment': comment}, follow=True)
     ok_(EventComment.objects.filter(pk=comment.id).exists())
Example #3
0
 def test_post_delete_event_comment_user_no_perms(self):
     """Test delete event comment as rep without delete permissions."""
     event = EventFactory.create()
     user = UserFactory.create(groups=['Rep'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': event.slug,
                                      'pk': comment.id})
     self.client.login(username=user.username, password='******')
     self.client.post(comment_delete, follow=True)
     ok_(EventComment.objects.filter(pk=comment.id).exists())
Example #4
0
 def test_post_delete_event_comment_user_no_perms(self):
     """Test delete event comment as rep without delete permissions."""
     event = EventFactory.create(slug='test-event')
     user = UserFactory.create(groups=['Rep'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': 'test-event',
                                      'pk': comment.id})
     self.client.login(username=user.username, password='******')
     self.client.post(comment_delete, follow=True)
     ok_(EventComment.objects.filter(pk=comment.id).exists())
Example #5
0
 def test_post_delete_event_comment_admin(self, mock_success):
     """Test delete event comment as admin."""
     event = EventFactory.create()
     user = UserFactory.create(groups=['Admin'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': event.slug,
                                      'pk': comment.id})
     self.client.login(username=user.username, password='******')
     response = self.client.post(comment_delete, follow=True)
     mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
     self.assertTemplateUsed(response, 'view_event.html')
Example #6
0
 def test_post_delete_event_comment_admin(self, mock_success):
     """Test delete event comment as admin."""
     event = EventFactory.create()
     user = UserFactory.create(groups=['Admin'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': event.slug,
                                      'pk': comment.id})
     with self.login(user) as client:
         response = client.post(comment_delete, follow=True)
     mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
     self.assertJinja2TemplateUsed(response, 'view_event.jinja')
Example #7
0
 def test_post_delete_event_comment_admin(self, mock_success):
     """Test delete event comment as admin."""
     event = EventFactory.create(slug='test-event')
     user = UserFactory.create(groups=['Admin'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={'slug': 'test-event',
                                      'pk': comment.id})
     self.client.login(username=user.username, password='******')
     response = self.client.post(comment_delete, follow=True)
     mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
     self.assertTemplateUsed(response, 'view_event.html')
Example #8
0
 def test_post_delete_event_comment_user_no_perms(self):
     """Test delete event comment as rep without delete permissions."""
     event = EventFactory.create()
     user = UserFactory.create(groups=['Rep'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={
                                  'slug': event.slug,
                                  'pk': comment.id
                              })
     with self.login(user) as client:
         client.post(comment_delete, follow=True)
     ok_(EventComment.objects.filter(pk=comment.id).exists())
Example #9
0
    def test_post_delete_event_comment_owner(self, mock_success):
        """ Test delete event comment as event comment owner."""
        event = EventFactory.create()
        user = UserFactory.create(groups=['Rep'])
        comment = EventCommentFactory.create(event=event, user=user)
        comment_delete = reverse('events_delete_event_comment',
                                 kwargs={'slug': event.slug,
                                         'pk': comment.id})
        self.client.login(username=user.username, password='******')
        response = self.client.post(comment_delete, follow=True)

        mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
        ok_(not EventComment.objects.filter(pk=comment.id).exists())
        self.assertTemplateUsed(response, 'view_event.html')
Example #10
0
 def test_post_delete_event_comment_admin(self, mock_success):
     """Test delete event comment as admin."""
     event = EventFactory.create()
     user = UserFactory.create(groups=['Admin'])
     comment = EventCommentFactory.create(event=event)
     comment_delete = reverse('events_delete_event_comment',
                              kwargs={
                                  'slug': event.slug,
                                  'pk': comment.id
                              })
     with self.login(user) as client:
         response = client.post(comment_delete, follow=True)
     mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
     self.assertJinja2TemplateUsed(response, 'view_event.jinja')
Example #11
0
    def test_post_delete_event_comment_owner(self, mock_success):
        """ Test delete event comment as event comment owner."""
        event = EventFactory.create(slug='test-event')
        user = UserFactory.create(groups=['Rep'])
        comment = EventCommentFactory.create(event=event, user=user)
        comment_delete = reverse('events_delete_event_comment',
                                 kwargs={'slug': 'test-event',
                                         'pk': comment.id})
        self.client.login(username=user.username, password='******')
        response = self.client.post(comment_delete, follow=True)

        mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
        ok_(not EventComment.objects.filter(pk=comment.id).exists())
        self.assertTemplateUsed(response, 'view_event.html')
Example #12
0
    def test_post_delete_event_comment_owner(self, mock_success):
        """ Test delete event comment as event comment owner."""
        event = EventFactory.create()
        user = UserFactory.create(groups=['Rep'])
        comment = EventCommentFactory.create(event=event, user=user)
        comment_delete = reverse('events_delete_event_comment',
                                 kwargs={
                                     'slug': event.slug,
                                     'pk': comment.id
                                 })
        with self.login(user) as client:
            response = client.post(comment_delete, follow=True)

        mock_success.assert_called_with(ANY, 'Comment successfully deleted.')
        ok_(not EventComment.objects.filter(pk=comment.id).exists())
        self.assertJinja2TemplateUsed(response, 'view_event.jinja')