Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.utils import unittest
- from postorius.forms import UserPreferences, DomainNew, ListNew, UserNew
- class UserPreferencesTest(unittest.TestCase):
- def test_form_fields_valid(self):
- form = UserPreferences({
- 'acknowledge_posts': 'True',
- 'hide_address': 'True',
- 'receive_list_copy': 'False',
- 'receive_own_postings': 'False',
- })
- self.assertTrue(form.is_valid())
- class DomainNewTest(unittest.TestCase):
- def setUp(self):
- self.form_data = {
- 'mail_host': 'mailman.most-desirable.org',
- 'web_host': 'http://mailman.most-desirable.org',
- 'description': 'The Most Desirable organization',
- 'contact_address': 'contact@mailman.most-desirable.org',
- }
- def test_form_fields_webhost(self):
- form = DomainNew(self.form_data)
- self.assertTrue(form.is_valid())
- def test_form_fields_webhost_invalid(self):
- self.form_data['web_host'] = 'mailman.most-desirable.org'
- form = DomainNew(self.form_data)
- self.assertFalse(form.is_valid())
- def test_form_fields_mailhost(self):
- form = DomainNew(self.form_data)
- self.assertTrue(form.is_valid())
- def test_form_fields_mailhost_invalid(self):
- self.form_data['mail_host'] = 'mailman.most-desirable..org'
- form = DomainNew(self.form_data)
- self.assertFalse(form.is_valid())
- class ListNewTest(unittest.TestCase):
- def setUp(self):
- self.form_data = {
- 'listname' : 'test_list1',
- 'mail_host': 'mailman.most-desirable.org',
- 'list_owner': 'james@example.com',
- 'advertised': True,
- 'description': 'The Most Desirable organization',
- }
- def test_form_fields_listname(self):
- form = ListNew(self.form_data)
- self.assertTrue(form.is_valid())
- def test_form_fields_listname_invalid(self):
- self.form_data['listname'] = 'test$list1'
- form = ListNew(self.form_data)
- self.assertFalse(form.is_valid())
- class UserNewTest(unittest.TestCase):
- def setUp(self):
- self.form_data = {
- 'display_name' : 'Pranjal Yadav',
- 'email' : 'pranjal@example.com',
- 'password' : 'password123',
- 'password_repeat' : 'password123',
- }
- def test_form_fields_password(self):
- form = UserNew(self.form_data)
- self.assertTrue(form.is_valid())
- def test_form_fields_password_invalid(self):
- self.form_data['password_repeat'] = 'random'
- form = UserNew(self.form_data)
- self.assertFalse(form.is_valid())
- def test_form_fields_email(self):
- form = UserNew(self.form_data)
- self.assertTrue(form.is_valid())
- def test_form_fields_email_invalid(self):
- self.form_data['email'] = 'pranjal@example..com'
- form = UserNew(self.form_data)
- self.assertFalse(form.is_valid())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement