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())
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())
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())
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())
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')
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')
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')
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())
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')
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')
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')
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')