From 07f80f37659dd3fc0abd112ab6f0fe350ef47ade Mon Sep 17 00:00:00 2001 From: INOPIAE Date: Thu, 10 Dec 2020 23:00:42 +0100 Subject: [PATCH] fix: missing finish button, some unit tests Change-Id: If3e844d7830654bad86df0e4a43957c8754b5892 --- .gitignore | 1 + motion.py | 2 +- tests/test_motion.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1b9d93c..5792f88 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ messages.pot messages.mo messages.po +/python_tests_xml diff --git a/motion.py b/motion.py index 8eaa350..e878616 100644 --- 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//vote/", methods=['POST']) @validate_motion_access_vote('vote') diff --git a/tests/test_motion.py b/tests/test_motion.py index b4ba907..2b95b1e 100644 --- a/tests/test_motion.py +++ b/tests/test_motion.py @@ -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= '' + 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= '' + 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= '' + 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= '' + self.assertNotIn(str.encode(testtext), result.data) + def test_finishMotion(self): self.db_sampledata() -- 2.39.2