[test] Create user in setup_database
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 10 Apr 2017 15:38:14 +0200
changeset 2611 6463152ee353
parent 2610 26dbed8bb1fe
child 2612 9220e0ebf255
[test] Create user in setup_database Having a standard user available in a security test makes sense.
test/test_schema.py
--- a/test/test_schema.py	Fri Mar 31 18:53:49 2017 +0200
+++ b/test/test_schema.py	Mon Apr 10 15:38:14 2017 +0200
@@ -267,9 +267,13 @@
 
     assertUnauthorized = testutils.assertUnauthorized
 
+    def setup_database(self):
+        with self.admin_access.cnx() as cnx:
+            self.create_user(cnx, login='alice')
+            cnx.commit()
+
     def test_profile(self):
         with self.admin_access.repo_cnx() as cnx:
-            self.create_user(cnx, login='alice')
             self.create_user(cnx, login='bob')
             cnx.commit()
         with self.new_access('alice').repo_cnx() as cnx:
@@ -347,16 +351,13 @@
             cnx.commit()
 
     def test_users_can_create_unit(self):
-        with self.admin_access.cnx() as cnx:
-            self.create_user(cnx, 'bob')
-        with self.new_access('bob').cnx() as cnx:
+        with self.new_access('alice').cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             cnx.commit()
 
     def test_users_can_clone(self):
         """Functional test for SEDA component clone."""
         with self.admin_access.repo_cnx() as cnx:
-            self.create_user(cnx, login='alice')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             cnx.commit()