diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-03-24 23:08:29 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-03-24 23:08:29 -0400 |
commit | ff84855c68c0259a03add207f2e3b313e0c17621 (patch) | |
tree | 3b3c4ec32a26d848ca1a9112e9ec0aa144efaf51 /askbot/tests | |
parent | a91dc795f94e9c159e3cc9ecd4131ac0511366dc (diff) | |
download | askbot-ff84855c68c0259a03add207f2e3b313e0c17621.tar.gz askbot-ff84855c68c0259a03add207f2e3b313e0c17621.tar.bz2 askbot-ff84855c68c0259a03add207f2e3b313e0c17621.zip |
added option to disable the big ask button
Diffstat (limited to 'askbot/tests')
-rw-r--r-- | askbot/tests/db_api_tests.py | 33 | ||||
-rw-r--r-- | askbot/tests/utils.py | 22 |
2 files changed, 45 insertions, 10 deletions
diff --git a/askbot/tests/db_api_tests.py b/askbot/tests/db_api_tests.py index 91c25867..8d775fd0 100644 --- a/askbot/tests/db_api_tests.py +++ b/askbot/tests/db_api_tests.py @@ -3,6 +3,7 @@ functions that happen on behalf of users e.g. ``some_user.do_something(...)`` """ +from bs4 import BeautifulSoup from django.core import exceptions from django.core.urlresolvers import reverse from django.test.client import Client @@ -667,3 +668,35 @@ class GroupTests(AskbotTestCase): self.assertEqual(acts[0].recipients.count(), 1) recipient = acts[0].recipients.all()[0] self.assertEqual(recipient, mod) + +class LinkPostingTests(AskbotTestCase): + + def assert_no_link(self, html): + soup = BeautifulSoup(html) + links = soup.findAll('a') + self.assertEqual(len(links), 0) + + def assert_has_link(self, html, url): + soup = BeautifulSoup(html) + links = soup.findAll('a') + self.assertTrue(len(links) > 0) + self.assertEqual(links[0]['href'], url) + + @with_settings( + EDITOR_TYPE='markdown', + MIN_REP_TO_SUGGEST_LINK=5, + MIN_REP_TO_INSERT_LINK=30 + ) + def test_admin_can_help_low_rep_user_insert_link(self): + #create a low rep user + low = self.create_user('low', reputation=10) + #create an admin + admin = self.create_user('admin', status='d') + #low re user posts a question with a link + text = 'hello, please read http://wikipedia.org' + question = self.post_question(user=low, body_text=text) + self.assert_no_link(question.html) + self.edit_question(user=admin, question=question, body_text=text + ' ok') + self.assert_has_link(question.html, 'http://wikipedia.org') + + diff --git a/askbot/tests/utils.py b/askbot/tests/utils.py index ee3cd37e..141f229a 100644 --- a/askbot/tests/utils.py +++ b/askbot/tests/utils.py @@ -96,11 +96,12 @@ class AskbotTestCase(TestCase): def create_user( self, - username = 'user', - email = None, - notification_schedule = None, - date_joined = None, - status = 'a' + username='user', + email=None, + notification_schedule=None, + date_joined=None, + reputation=1, + status='a' ): """creates user with username, etc and makes the result accessible as @@ -116,11 +117,12 @@ class AskbotTestCase(TestCase): email = username + '@example.com' user_object = create_user( - username = username, - email = email, - notification_schedule = notification_schedule, - date_joined = date_joined, - status = status + username=username, + email=email, + notification_schedule=notification_schedule, + date_joined=date_joined, + status=status, + reputation=reputation ) setattr(self, username, user_object) |