summaryrefslogtreecommitdiffstats
path: root/askbot/tests/form_tests.py
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-08-07 19:24:12 -0600
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-08-07 19:24:12 -0600
commit460c64735ae3980dce0f094ca2a783e6bc8e0cef (patch)
treeba0c13f35287281badec7e8fd7e742ab1d92e36e /askbot/tests/form_tests.py
parentea41edaebcee3fac90fa3bcdb77be1902c442f4e (diff)
downloadaskbot-460c64735ae3980dce0f094ca2a783e6bc8e0cef.tar.gz
askbot-460c64735ae3980dce0f094ca2a783e6bc8e0cef.tar.bz2
askbot-460c64735ae3980dce0f094ca2a783e6bc8e0cef.zip
Initial work for widget creation
Widgets will work with iframes and javascript code to insert them. DONE: - View to ask a question - Form to ask a question - Initial work on templates. (no css yet) - Test for all the former TODO: - create widget builder view. - documentation, documentation, documentation! - Login view with special template and css.
Diffstat (limited to 'askbot/tests/form_tests.py')
-rw-r--r--askbot/tests/form_tests.py33
1 files changed, 27 insertions, 6 deletions
diff --git a/askbot/tests/form_tests.py b/askbot/tests/form_tests.py
index a37f380c..be88cf39 100644
--- a/askbot/tests/form_tests.py
+++ b/askbot/tests/form_tests.py
@@ -72,8 +72,8 @@ class AskByEmailFormTests(AskbotTestCase):
askbot_settings.update('TAGS_ARE_REQUIRED', setting_backup)
def test_email(self):
- """loops through variants of the from field
- in the emails and tests the email address
+ """loops through variants of the from field
+ in the emails and tests the email address
extractor"""
for test_case in EMAIL_CASES:
self.data['sender'] = test_case[0]
@@ -178,7 +178,7 @@ class EditQuestionAnonymouslyFormTests(AskbotTestCase):
def setup_data(self, is_anon, can_be_anon, is_owner, box_checked):
"""sets up data in the same order as shown in the
truth table above
-
+
the four positional arguments are in the same order
"""
askbot_settings.update('ALLOW_ASK_ANONYMOUSLY', can_be_anon)
@@ -264,7 +264,7 @@ class UserStatusFormTest(AskbotTestCase):
self.moderator.set_status('m')
self.subject = self.create_user('normal_user')
self.subject.set_status('a')
- self.form = forms.ChangeUserStatusForm(data, moderator = self.moderator,
+ self.form = forms.ChangeUserStatusForm(data, moderator = self.moderator,
subject = self.subject)
def test_moderator_can_suspend_user(self):
self.setup_data('s')
@@ -292,7 +292,7 @@ class UserNameFieldTest(AskbotTestCase):
self.username_field.skip_clean = True
self.assertEquals(self.username_field.clean('bar'), 'bar')#will pass anything
- self.username_field.skip_clean = False
+ self.username_field.skip_clean = False
#will not pass b/c instance is not User model
self.username_field.user_instance = dict(foo=1)
@@ -328,7 +328,7 @@ class AnswerEditorFieldTests(AskbotTestCase):
self.field.clean,
'a'
)
-
+
def test_pass_long_body(self):
self.assertEquals(
self.field.clean(10*'a'),
@@ -361,3 +361,24 @@ class PostAsSomeoneFormTests(AskbotTestCase):
def test_missing_username_fails(self):
form = forms.PostAsSomeoneForm({'post_author_email': 'me@example.com'})
self.assertEqual(form.is_valid(), False)
+
+class AskWidgetFormTests(AskbotTestCase):
+
+ form = forms.AskWidgetForm
+
+ def setUp(self):
+ self.good_data = {'title': "What's the price of a house in london?"}
+ self.good_data_anon = {'title': "What's the price of a house in london?",
+ 'ask_anonymously': True}
+
+ self.bad_data = {'title': ''}
+
+ def test_valid_input(self):
+ form_object = self.form(self.good_data)
+ self.assertTrue(form_object.is_valid())
+ form_object = self.form(self.good_data_anon)
+ self.assertTrue(form_object.is_valid())
+
+ def test_invalid_input(self):
+ form_object = self.form(self.bad_data)
+ self.assertFalse(form_object.is_valid())