summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-10-14 02:13:42 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-10-14 02:13:42 -0300
commit3c6a182685ad217129271dfd77280b3710242777 (patch)
treebe606cbdd4666bc20967c1f587c8d12bee168c27
parent5fd9a8bc5de3649ca6423377baec96f527f863e5 (diff)
downloadaskbot-3c6a182685ad217129271dfd77280b3710242777.tar.gz
askbot-3c6a182685ad217129271dfd77280b3710242777.tar.bz2
askbot-3c6a182685ad217129271dfd77280b3710242777.zip
added test cases for making private posts, some tests fail
-rw-r--r--askbot/tests/__init__.py1
-rw-r--r--askbot/tests/question_views_tests.py89
2 files changed, 90 insertions, 0 deletions
diff --git a/askbot/tests/__init__.py b/askbot/tests/__init__.py
index 59db8f67..7e7e3c48 100644
--- a/askbot/tests/__init__.py
+++ b/askbot/tests/__init__.py
@@ -18,6 +18,7 @@ from askbot.tests.haystack_search_tests import *
from askbot.tests.email_parsing_tests import *
from askbot.tests.widget_tests import *
from askbot.tests.category_tree_tests import CategoryTreeTests
+from askbot.tests.question_views_tests import *
from askbot.tests.user_model_tests import UserModelTests
from askbot.tests.user_views_tests import *
from askbot.tests.utils_tests import *
diff --git a/askbot/tests/question_views_tests.py b/askbot/tests/question_views_tests.py
new file mode 100644
index 00000000..d6e64101
--- /dev/null
+++ b/askbot/tests/question_views_tests.py
@@ -0,0 +1,89 @@
+from bs4 import BeautifulSoup
+from askbot.conf import settings as askbot_settings
+from askbot import const
+from askbot.tests.utils import AskbotTestCase
+from askbot import models
+from askbot.models.tag import get_global_group
+from django.core.urlresolvers import reverse
+
+
+class PrivateQuestionViewsTests(AskbotTestCase):
+
+ def setUp(self):
+ self._backup = askbot_settings.GROUPS_ENABLED
+ askbot_settings.update('GROUPS_ENABLED', True)
+ self.user = self.create_user('user')
+ self.group = models.Group.objects.create(
+ name='the group', openness=models.Group.OPEN
+ )
+ self.user.join_group(self.group)
+ self.qdata = {
+ 'title': 'test question title',
+ 'text': 'test question text'
+ }
+ self.client.login(user_id=self.user.id, method='force')
+
+ def tearDown(self):
+ askbot_settings.update('GROUPS_ENABLED', self._backup)
+
+ def test_post_private_question(self):
+ data = self.qdata
+ data['post_privately'] = 'true'
+ response1 = self.client.post(reverse('ask'), data=data)
+ response2 = self.client.get(response1['location'])
+ dom = BeautifulSoup(response2.content)
+ title = dom.find('h1').text
+ self.assertTrue(const.POST_STATUS['private'] in title)
+ question = models.Thread.objects.get(id=1)
+ self.assertEqual(question.title, self.qdata['title'])
+ self.assertFalse(get_global_group() in set(question.groups.all()))
+
+ def test_publish_private_question(self):
+ question = self.post_question(user=self.user, is_private=True)
+ title = question.thread.get_title()
+ self.assertTrue(const.POST_STATUS['private'] in title)
+ data = self.qdata
+ data['post_privately'] = 'false'
+ data['select_revision'] = 'false'
+ response1 = self.client.post(
+ reverse('edit_question', kwargs={'id':question.id}),
+ data=data
+ )
+ response2 = self.client.get(question.get_absolute_url())
+ dom = BeautifulSoup(response2.content)
+ title = dom.find('h1').text
+ self.assertTrue(get_global_group() in set(question.groups.all()))
+ #todo: fix this fail
+ self.assertEqual(title, self.qdata['title'])
+
+ def test_privatize_public_question(self):
+ question = self.post_question(user=self.user, is_private=True)
+ title = question.thread.get_title()
+ self.assertTrue(const.POST_STATUS['private'] in title)
+ data = self.qdata
+ data['post_privately'] = 'true'
+ data['select_revision'] = 'false'
+ response1 = self.client.post(
+ reverse('edit_question', kwargs={'id':question.id}),
+ data=data
+ )
+ response2 = self.client.get(question.get_absolute_url())
+ dom = BeautifulSoup(response2.content)
+ title = dom.find('h1').text
+ self.assertFalse(get_global_group() in set(question.groups.all()))
+ self.assertTrue(const.POST_STATUS['private'] in title)
+
+ def test_private_checkbox_is_on_when_editing_private_question(self):
+ pass
+
+ def test_private_checkbox_is_off_when_editing_public_question(self):
+ pass
+
+ def test_private_answer(self):
+ pass
+
+ def test_publish_private_answer(self):
+ pass
+
+ def test_privatize_public_answer(self):
+ pass