|
@@ -5,6 +5,7 @@ from django.contrib.auth.models import User
|
|
|
from django.test import TestCase, Client, override_settings
|
|
|
|
|
|
from contribmap.models import Contrib
|
|
|
+from contribmap.forms import PublicContribForm
|
|
|
|
|
|
|
|
|
class APITestClient(Client):
|
|
@@ -132,6 +133,41 @@ class TestViews(APITestCase):
|
|
|
self.assertIn('JohnCleese', mail.outbox[0].subject)
|
|
|
self.assertIn('JohnCleese', mail.outbox[0].body)
|
|
|
|
|
|
+class TestForms(TestCase):
|
|
|
+ valid_data = {
|
|
|
+ 'roof': True,
|
|
|
+ 'privacy_place_details': True,
|
|
|
+ 'privacy_coordinates': True,
|
|
|
+ 'orientations': ['N'],
|
|
|
+ 'orientation': 'all',
|
|
|
+ 'name': 'JohnCleese',
|
|
|
+ 'longitude': -1.553621,
|
|
|
+ 'email': 'foo@example.com',
|
|
|
+ 'phone': '0202020202',
|
|
|
+ 'latitude': 47.218371,
|
|
|
+ 'floor_total': '2',
|
|
|
+ 'floor': 1,
|
|
|
+ 'contrib_type': 'connect',
|
|
|
+ 'connect_local': 'on',
|
|
|
+ }
|
|
|
+
|
|
|
+ def test_contact_validation(self):
|
|
|
+ no_contact, phone_contact, email_contact, both_contact = [
|
|
|
+ self.valid_data.copy() for i in range(4)]
|
|
|
+
|
|
|
+ del phone_contact['email']
|
|
|
+ del email_contact['phone']
|
|
|
+ del no_contact['phone']
|
|
|
+ del no_contact['email']
|
|
|
+
|
|
|
+ both_contact.update(phone_contact)
|
|
|
+ both_contact.update(email_contact)
|
|
|
+
|
|
|
+ self.assertFalse(PublicContribForm(no_contact).is_valid())
|
|
|
+ self.assertTrue(PublicContribForm(phone_contact).is_valid())
|
|
|
+ self.assertTrue(PublicContribForm(email_contact).is_valid())
|
|
|
+ self.assertTrue(PublicContribForm(both_contact).is_valid())
|
|
|
+
|
|
|
|
|
|
class TestDataImport(TestCase):
|
|
|
fixtures = ['bottle_data.yaml']
|