[PATCH 1 of 5 seda] [test] Create user in setup_database

Sylvain Thenault sylvain.thenault at logilab.fr
Mon Apr 10 17:48:32 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1491831494 -7200
#      Mon Apr 10 15:38:14 2017 +0200
# Node ID 8f62b2d83afd4a325178ae4aa6908d9b8567c408
# Parent  5c8d72283fc67366d645f4610dd3e4bec76648ca
[test] Create user in setup_database

Having a standard user available in a security test makes sense.

diff --git a/test/test_schema.py b/test/test_schema.py
--- a/test/test_schema.py
+++ b/test/test_schema.py
@@ -265,13 +265,17 @@ class SchemaTC(CubicWebTC):
 
 class SecurityTC(CubicWebTC):
 
     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:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Alice Profile')
             testutils.create_archive_unit(transfer)
@@ -345,20 +349,17 @@ class SecurityTC(CubicWebTC):
             unit = cnx.entity_from_eid(unit.eid)
             unit.cw_delete()
             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()
 
         with self.new_access('alice').repo_cnx() as cnx:
             unit = cnx.entity_from_eid(unit.eid)


More information about the saem-devel mailing list