def test_topic_moderate_unpin(self): """ topic unpin """ def topic_post_moderate_handler(sender, user, topic, action, **kwargs): self._moderate = [repr(user._wrapped), repr(topic), action] topic_post_moderate.connect(topic_post_moderate_handler) utils.login(self) self.user.is_moderator = True self.user.save() category = utils.create_category() topic = utils.create_topic(category, is_pinned=True) form_data = {} response = self.client.post( reverse('spirit:topic-unpin', kwargs={ 'pk': topic.pk, }), form_data) expected_url = topic.get_absolute_url() self.assertRedirects(response, expected_url, status_code=302) self.assertFalse(Topic.objects.get(pk=topic.pk).is_pinned) self.assertEqual( self._moderate, [repr(self.user), repr(topic), UNPINNED])
def test_topic_update_signal(self): """ POST, topic moved to category """ def topic_post_moderate_handler(sender, user, topic, action, **kwargs): self._moderate = [repr(user._wrapped), repr(topic), action] topic_post_moderate.connect(topic_post_moderate_handler) utils.login(self) self.user.is_moderator = True self.user.save() category = utils.create_category() topic = utils.create_topic(category=category, user=self.user) category2 = utils.create_category() form_data = {'title': 'foobar', 'category': category2.pk} response = self.client.post( reverse('spirit:topic-update', kwargs={ 'pk': topic.pk, }), form_data) self.assertSequenceEqual( self._moderate, [repr(self.user), repr(Topic.objects.get(pk=topic.pk)), MOVED])
def test_topic_update_signal(self): """ POST, topic moved to category """ def topic_post_moderate_handler(sender, user, topic, action, **kwargs): self._moderate = [repr(user._wrapped), repr(topic), action] topic_post_moderate.connect(topic_post_moderate_handler) utils.login(self) self.user.is_moderator = True self.user.save() category = utils.create_category() topic = utils.create_topic(category=category, user=self.user) category2 = utils.create_category() form_data = {'title': 'foobar', 'category': category2.pk} response = self.client.post(reverse('spirit:topic-update', kwargs={'pk': topic.pk, }), form_data) self.assertSequenceEqual(self._moderate, [repr(self.user), repr(Topic.objects.get(pk=topic.pk)), MOVED])
def test_topic_moderate_unpin(self): """ topic unpin """ def topic_post_moderate_handler(sender, user, topic, action, **kwargs): self._moderate = [repr(user._wrapped), repr(topic), action] topic_post_moderate.connect(topic_post_moderate_handler) utils.login(self) self.user.is_moderator = True self.user.save() category = utils.create_category() topic = utils.create_topic(category, is_pinned=True) form_data = {} response = self.client.post(reverse('spirit:topic-unpin', kwargs={'pk': topic.pk, }), form_data) expected_url = topic.get_absolute_url() self.assertRedirects(response, expected_url, status_code=302) self.assertFalse(Topic.objects.get(pk=topic.pk).is_pinned) self.assertEqual(self._moderate, [repr(self.user), repr(topic), UNPINNED])