|
@@ -1,7 +1,8 @@
|
|
|
import json
|
|
|
|
|
|
+from django.core import mail
|
|
|
from django.contrib.auth.models import User
|
|
|
-from django.test import TestCase, Client
|
|
|
+from django.test import TestCase, Client, override_settings
|
|
|
|
|
|
from contribmap.models import Contrib
|
|
|
|
|
@@ -100,6 +101,37 @@ class TestViews(APITestCase):
|
|
|
response = self.client.get('/map/private.json')
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
+ @override_settings(NOTIFICATION_EMAILS=['foo@example.com'])
|
|
|
+ def test_add_contrib_sends_email(self):
|
|
|
+ response = self.client.post('/map/contribute', {
|
|
|
+ 'roof': True,
|
|
|
+ 'privacy_place_details': True,
|
|
|
+ 'privacy_coordinates': True,
|
|
|
+ 'phone': '0202020202',
|
|
|
+ 'orientations': 'N',
|
|
|
+ 'orientations': 'NO',
|
|
|
+ 'orientations': 'O',
|
|
|
+ 'orientations': 'SO',
|
|
|
+ 'orientations': 'S',
|
|
|
+ 'orientations': 'SE',
|
|
|
+ 'orientations': 'E',
|
|
|
+ 'orientations': 'NE',
|
|
|
+ 'orientation': 'all',
|
|
|
+ 'name': 'JohnCleese',
|
|
|
+ 'longitude': -1.553621,
|
|
|
+ 'latitude': 47.218371,
|
|
|
+ 'floor_total': '2',
|
|
|
+ 'floor': 1,
|
|
|
+ 'email': 'coucou@example.com',
|
|
|
+ 'contrib_type': 'connect',
|
|
|
+ 'connect_local': 'on',
|
|
|
+ })
|
|
|
+ self.assertEqual(response.status_code, 302)
|
|
|
+
|
|
|
+ self.assertEqual(len(mail.outbox), 1)
|
|
|
+ self.assertIn('JohnCleese', mail.outbox[0].subject)
|
|
|
+ self.assertIn('JohnCleese', mail.outbox[0].body)
|
|
|
+
|
|
|
|
|
|
class TestDataImport(TestCase):
|
|
|
fixtures = ['bottle_data.yaml']
|