]> WPIA git - motion.git/commitdiff
fix: missing finish button, some unit tests
authorINOPIAE <m.maengel@inopiae.de>
Thu, 10 Dec 2020 22:00:42 +0000 (23:00 +0100)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 10 Dec 2020 22:16:52 +0000 (23:16 +0100)
Change-Id: If3e844d7830654bad86df0e4a43957c8754b5892

.gitignore
motion.py
tests/test_motion.py

index 1b9d93c37830a382949691bf6a41935b2dbd4df6..5792f882d5691bd4d9c142864083c54a3edf71aa 100644 (file)
@@ -14,3 +14,4 @@
 messages.pot
 messages.mo
 messages.po
+/python_tests_xml
index 8eaa3501214926263fa271255c2fdf90633a1c38..e878616065ba72baabbe532636179aa909949eac 100644 (file)
--- a/motion.py
+++ b/motion.py
@@ -372,7 +372,7 @@ def show_motion(motion):
     if may("audit", resultmotion[0].get("type")) and not resultmotion[0].get("running") and not resultmotion[0].get("canceled"):
         votes = get_db().prepare("SELECT vote.result, voter.email FROM vote INNER JOIN voter ON voter.id = vote.voter_id WHERE vote.motion_id=$1")(resultmotion[0].get("id"));
         votes = get_db().prepare("SELECT vote.result, voter.email, CASE voter.email WHEN proxy.email THEN NULL ELSE proxy.email END as proxyemail FROM vote INNER JOIN voter ON voter.id = vote.voter_id INNER JOIN voter as proxy ON proxy.id = vote.proxy_id WHERE vote.motion_id=$1")(resultmotion[0].get("id"));
-    return render_template('single_motion.html', motion=resultmotion[0], may_vote=may("vote", resultmotion[0].get("type")), may_cancel=may("cancel", resultmotion[0].get("type")), votes=votes, proxyvote=resultproxyvote, proxyname=resultproxyname, languages=get_languages())
+    return render_template('single_motion.html', motion=resultmotion[0], may_vote=may("vote", resultmotion[0].get("type")), may_cancel=may("cancel", resultmotion[0].get("type")), may_finish=may("finish", resultmotion[0].get("type")), votes=votes, proxyvote=resultproxyvote, proxyname=resultproxyname, languages=get_languages())
 
 @app.route("/motion/<string:motion>/vote/<string:voter>", methods=['POST'])
 @validate_motion_access_vote('vote')
index b4ba9070980806a21c41f958626e50128c2364fe..2b95b1e42291438ab506c1a49a16c77236a4faea 100644 (file)
@@ -400,6 +400,19 @@ class CreateMotionTests(BasicTest):
         self.assertEqual(response.status_code, 403)
         self.assertIn(str.encode('Forbidden'), response.data)
 
+    def test_SeeCancelMotion(self):
+        self.db_sampledata()
+
+        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>'
+        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>'
+        self.assertNotIn(str.encode(testtext), result.data)
+
     def test_cancelMotion(self):
         self.db_sampledata()
 
@@ -432,6 +445,19 @@ class CreateMotionTests(BasicTest):
         self.assertEqual(response.status_code, 403)
         self.assertIn(str.encode('Error, motion was canceled'), response.data)
 
+    def test_SeeFinishMotion(self):
+        self.db_sampledata()
+
+        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>'
+        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>'
+        self.assertNotIn(str.encode(testtext), result.data)
+
     def test_finishMotion(self):
         self.db_sampledata()