Parcourir la source

robot prevention : tests

Signed-off-by: CapsLock <faimaison@legeox.net>
CapsLock il y a 9 ans
Parent
commit
9b30db6db4
1 fichiers modifiés avec 29 ajouts et 0 suppressions
  1. 29 0
      wifiwithme/apps/contribmap/tests.py

+ 29 - 0
wifiwithme/apps/contribmap/tests.py

@@ -132,6 +132,35 @@ class TestViews(APITestCase):
         self.assertIn('JohnCleese', mail.outbox[0].subject)
         self.assertIn('JohnCleese', mail.outbox[0].body)
 
+    @override_settings(NOTIFICATION_EMAILS=['foo@example.com'])
+    def test_add_contrib_like_a_robot(self):
+        response = self.client.post('/map/contribute', {
+            'roof': True,
+            'human_field': 'should not have no value',
+            '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, 403)
+        self.assertEqual(len(mail.outbox), 0)
+
 
 class TestDataImport(TestCase):
     fixtures = ['bottle_data.yaml']