]> WPIA git - motion.git/blobdiff - tests/test_motion.py
some test cleanup
[motion.git] / tests / test_motion.py
index 3fc34bd0af42c81071b91ef7f420a510442c50d0..6ec2e1bef57e068585ada4f9d0c89005bc1c96a6 100644 (file)
@@ -5,6 +5,12 @@ from unittest import TestCase
 from motion import app
 from datetime import datetime
 
+app.config.update(
+    DEBUGUSER = {},
+    GROUP_PREFIX = {'127.0.0.1:5000': {'group1': 'g1', 'group2': 'g2'}},
+    DURATION = {'127.0.0.1:5000':[3, 7, 14]}
+)
+
 class BasicTest(TestCase):
 
     # functions to manipulate motions
@@ -37,14 +43,14 @@ class BasicTest(TestCase):
 
     # functions to clear database
     def db_clear(self):
-        db = postgresql.open(app.config.get("DATABASE"), user=app.config.get("USER"), password=app.config.get("PASSWORD"))
-        with app.open_resource('sql/schema.sql', mode='r') as f:
-            db.execute(f.read())
+        with postgresql.open(app.config.get("DATABASE"), user=app.config.get("USER"), password=app.config.get("PASSWORD")) as db:
+            with app.open_resource('sql/schema.sql', mode='r') as f:
+                db.execute(f.read())
 
     def db_sampledata(self):
-        db = postgresql.open(app.config.get("DATABASE"), user=app.config.get("USER"), password=app.config.get("PASSWORD"))
-        with app.open_resource('sql/sample_data.sql', mode='r') as f:
-            db.execute(f.read())
+        with postgresql.open(app.config.get("DATABASE"), user=app.config.get("USER"), password=app.config.get("PASSWORD")) as db:
+            with app.open_resource('sql/sample_data.sql', mode='r') as f:
+                db.execute(f.read())
 
 
 # no specific rights required
@@ -222,7 +228,7 @@ class VoterTests(BasicTest):
         response = self.createVote(user, motion, 'no')
         self.assertEqual(response.status_code, 302)
         result = self.app.get('/', environ_base={'USER_ROLES': user})
-         resulttext=self.buildResultText('A fourth motion', 0, 1, 0)
+        resulttext=self.buildResultText('A fourth motion', 0, 1, 0)
         self.assertIn(str.encode(resulttext), result.data)
         response = self.createVote(user, motion, 'abstain')
         self.assertEqual(response.status_code, 302)