]> WPIA git - motion.git/blobdiff - tests/test_motion.py
upd: move cancel and finish button and add confirm question
[motion.git] / tests / test_motion.py
index f6992968ff128e05375539cc51ba1d4f19e9ff54..436c06f446275a35c0a1b467e7722306475c3cf8 100644 (file)
@@ -1,6 +1,5 @@
 from datetime import datetime
 from tests.test_basics import BasicTest
-import postgresql
 from motion import app
 
 # no specific rights required
@@ -407,12 +406,14 @@ class CreateMotionTests(BasicTest):
 
         motion='g1.20200402.004'
         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
-        testtext= '<button type="submit" class="btn btn-danger" name="cancel" value="cancel" id="cancel">Cancel</button>'
+        testtext= '<button type="submit" class="btn btn-danger btn-confirm" data-confirm="Do you really want to cancel the motion?" '\
+            + 'data-reply="Cancel,Confirm" name="cancel" value="cancel" id="cancel">Cancel</button>'
         self.assertIn(str.encode(testtext), result.data)
 
         motion='g1.20200402.004'
         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': 'testuser/vote:*'}, follow_redirects=True)
-        testtext= '<button type="submit" class="btn btn-danger" name="cancel" value="cancel" id="cancel">Cancel</button>'
+        testtext= '<button type="submit" class="btn btn-danger btn-confirm" data-confirm="Do you really want to cancel the motion?" '\
+            + 'data-reply="Cancel,Confirm" name="cancel" value="cancel" id="cancel">Cancel</button>'
         self.assertNotIn(str.encode(testtext), result.data)
 
     def test_cancelMotion(self):
@@ -452,12 +453,14 @@ class CreateMotionTests(BasicTest):
 
         motion='g1.20200402.004'
         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
-        testtext= '<button type="submit" class="btn btn-danger" name="finish" value="finish" id="finish">Finish</button>'
+        testtext= '<button type="submit" class="btn btn-danger btn-confirm" data-confirm="Do you really want to finish the motion?" '\
+            + 'data-reply="Cancel,Confirm" name="finish" value="finish" id="finish">Finish</button>'
         self.assertIn(str.encode(testtext), result.data)
 
         motion='g1.20200402.004'
         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': 'testuser/vote:*'}, follow_redirects=True)
-        testtext= '<button type="submit" class="btn btn-danger" name="finish" value="finish" id="finish">Finish</button>'
+        testtext= '<button type="submit" class="btn btn-danger btn-confirm" data-confirm="Do you really want to finish the motion?" '\
+            + 'data-reply="Cancel,Confirm" name="finish" value="finish" id="finish">Finish</button>'
         self.assertNotIn(str.encode(testtext), result.data)
 
     def test_finishMotion(self):
@@ -479,6 +482,24 @@ class CreateMotionTests(BasicTest):
         self.assertEqual(response.status_code, 403)
         self.assertIn(str.encode('Error, out of time'), response.data)
 
+    def test_createMotionWait(self):
+        # test no limit given
+        self.db_sampledata()
+        title='My Motion'
+        content='My body'
+        response = self.createMotion(user, title, content, '3', 'group1')
+        self.assertEqual(response.status_code, 302)
+
+        # test different host
+        app.config.update(MOTION_WAIT_MINUTES={'127.0.0.1:5001':1})
+        response = self.createMotion(user, title, content, '3', 'group1')
+        self.assertEqual(response.status_code, 302)
+
+        # test 3 minutes
+        app.config.update(MOTION_WAIT_MINUTES={'127.0.0.1:5000':3})
+        response = self.createMotion(user, title, content, '3', 'group1')
+        self.assertIn(str.encode('Error, time between last motion to short. The current setting is 3 minute(s).'), response.data)
+
 class AuditMotionTests(BasicTest):
 
     def setUp(self):