Changeset: 3844b3f5d0ee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3844b3f5d0ee
Removed Files:
        sql/test/Tests/comment-auth-a.sql
        sql/test/Tests/comment-auth-superuser.sql
        sql/test/Tests/comment-auth-superuser.test
Modified Files:
        sql/test/Tests/comment-auth.SQL.py
Branch: mtest
Log Message:

Fix comment-auth test

Exit with error status if a difference is detected.

Inline sql inputs comment-auth-{superuser,a}.sql so they
can no longer be mistaken for independent tests.


diffs (158 lines):

diff --git a/sql/test/Tests/comment-auth-a.sql 
b/sql/test/Tests/comment-auth-a.sql
deleted file mode 100644
--- a/sql/test/Tests/comment-auth-a.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-
--- can we see the comments set by the super user?
-\dn
-
--- we cannot change comments on objects we don't own
-COMMENT ON SCHEMA schema_b IS 'set by user_a';
-
--- but we can comment on our own stuff
-COMMENT ON SCHEMA schema_a IS 'set by user_a';
-\dn
diff --git a/sql/test/Tests/comment-auth-superuser.sql 
b/sql/test/Tests/comment-auth-superuser.sql
deleted file mode 100644
--- a/sql/test/Tests/comment-auth-superuser.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-
-CREATE USER user_a WITH PASSWORD 'user_a' NAME 'User A' SCHEMA sys;
-CREATE USER user_b WITH PASSWORD 'user_b' NAME 'User B' SCHEMA sys;
-CREATE ROLE role_b;
-GRANT role_b to user_b;
-
-CREATE SCHEMA schema_a AUTHORIZATION user_a;
-CREATE SCHEMA schema_b AUTHORIZATION role_b;
-
-CREATE TABLE schema_a.tab_a(i INTEGER);
-CREATE TABLE schema_b.tab_b(i INTEGER);
-
-COMMENT ON SCHEMA schema_a IS 'set by super user';
-COMMENT ON SCHEMA schema_b IS 'set by super user';
diff --git a/sql/test/Tests/comment-auth-superuser.test 
b/sql/test/Tests/comment-auth-superuser.test
deleted file mode 100644
--- a/sql/test/Tests/comment-auth-superuser.test
+++ /dev/null
@@ -1,30 +0,0 @@
-statement error
-CREATE USER user_a WITH PASSWORD 'user_a' NAME 'User A' SCHEMA sys
-
-statement error
-CREATE USER user_b WITH PASSWORD 'user_b' NAME 'User B' SCHEMA sys
-
-statement error
-CREATE ROLE role_b
-
-statement error
-GRANT role_b to user_b
-
-statement error
-CREATE SCHEMA schema_a AUTHORIZATION user_a
-
-statement error
-CREATE SCHEMA schema_b AUTHORIZATION role_b
-
-statement error
-CREATE TABLE schema_a.tab_a(i INTEGER)
-
-statement error
-CREATE TABLE schema_b.tab_b(i INTEGER)
-
-statement ok
-COMMENT ON SCHEMA schema_a IS 'set by super user'
-
-statement ok
-COMMENT ON SCHEMA schema_b IS 'set by super user'
-
diff --git a/sql/test/Tests/comment-auth.SQL.py 
b/sql/test/Tests/comment-auth.SQL.py
--- a/sql/test/Tests/comment-auth.SQL.py
+++ b/sql/test/Tests/comment-auth.SQL.py
@@ -5,39 +5,74 @@ except ImportError:
     import process
 
 # As super user, create users and schemas owned by these users.
+
+SUPERUSER_SCRIPT = """
+CREATE USER user_a WITH PASSWORD 'user_a' NAME 'User A' SCHEMA sys;
+CREATE USER user_b WITH PASSWORD 'user_b' NAME 'User B' SCHEMA sys;
+CREATE ROLE role_b;
+GRANT role_b to user_b;
+
+CREATE SCHEMA schema_a AUTHORIZATION user_a;
+CREATE SCHEMA schema_b AUTHORIZATION role_b;
+
+CREATE TABLE schema_a.tab_a(i INTEGER);
+CREATE TABLE schema_b.tab_b(i INTEGER);
+
+COMMENT ON SCHEMA schema_a IS 'set by super user';
+COMMENT ON SCHEMA schema_b IS 'set by super user';
+"""
+
 with process.client('sql',
-                    stdin = open(os.path.join(os.getenv('TSTSRCDIR'),
-                                              'comment-auth-superuser.sql')),
+                    stdin = process.PIPE,
                     stdout = process.PIPE, stderr = process.PIPE) as c:
-    out, err = c.communicate()
+    out, err = c.communicate(SUPERUSER_SCRIPT)
     if re.search(r'^[^#\n]', out, re.M):
         sys.stdout.write(out)
+        sys.exit(1)
     if re.search(r'^[^#\n]', err, re.M):
         sys.stderr.write(err)
+        sys.exit(1)
 
-dump = '''\
+
+USER_A_SCRIPT = r"""
+-- can we see the comments set by the super user?
+\dn
+
+-- we cannot change comments on objects we don't own
+COMMENT ON SCHEMA schema_b IS 'set by user_a';
+
+-- but we can comment on our own stuff
+COMMENT ON SCHEMA schema_a IS 'set by user_a';
+\dn
+"""
+
+# As one of the users, check that we can only comment on our own objects.
+
+USER_A_STDOUT = '''\
 SCHEMA schema_a 'set by super user'
 SCHEMA schema_b 'set by super user'
 SCHEMA schema_a 'set by user_a'
 SCHEMA schema_b 'set by super user'
 '''
-edump = r'''\
+
+USER_A_STDERR = r'''\
 MAPI = (user_a) /var/tmp/mtest-285315/.s.monetdb.\d+
 QUERY = COMMENT ON SCHEMA schema_b IS 'set by user_a';
 ERROR = !COMMENT ON: insufficient privileges for user 'user_a' in schema 
'schema_b'
 CODE = 42000
 '''
-# As one of the users, check that we can only comment on our own objects.
+
 with process.client('sql',
                     user='user_a', passwd='user_a',
-                    stdin=open(os.path.join(os.getenv('TSTSRCDIR'),
-                                              'comment-auth-a.sql')),
+                    stdin=process.PIPE,
                     echo=False,
                     stdout=process.PIPE, stderr=process.PIPE) as c:
-    out, err = c.communicate()
+    out, err = c.communicate(USER_A_SCRIPT)
     out = ' '.join(re.split('[ \t]+', out))
-    if out != dump:
+    if out != USER_A_STDOUT:
         sys.stdout.write(out)
+        sys.exit(1)
     err = ' '.join(re.split('[ \t]+', err))
-    if re.match(edump, err) is not None:
+    if re.match(USER_A_STDERR, err) is not None:
         sys.stderr.write(err)
+        sys.exit(1)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to