Changeset: 2f117460182e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2f117460182e
Modified Files:
        sql/test/Users/Tests/copyinto.SQL.py
Branch: mtest
Log Message:

convert tests for copyinto


diffs (116 lines):

diff --git a/sql/test/Users/Tests/copyinto.SQL.py 
b/sql/test/Users/Tests/copyinto.SQL.py
--- a/sql/test/Users/Tests/copyinto.SQL.py
+++ b/sql/test/Users/Tests/copyinto.SQL.py
@@ -1,45 +1,77 @@
 import os, sys
-try:
-    from MonetDBtesting import process
-except ImportError:
-    import process
 
 TSTSRCBASE = os.environ['TSTSRCBASE']
 SRCDIR = os.path.join(TSTSRCBASE, "sql", "benchmarks", "tpch")
 DATADIR = os.path.join(SRCDIR,"SF-0.01")
 
-with process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr 
= process.PIPE) as c:
-    c.stdin.write("CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL, R_NAME 
CHAR(25) NOT NULL, R_COMMENT VARCHAR(152));\n")
-    c.stdin.write("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS '|', 
E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
-    c.stdin.write("select count(*) from region;\n")
-    c.stdin.write("CREATE USER copyuser WITH PASSWORD 'copyuser' name 
'copyuser' schema sys;\n")
-    c.stdin.write("GRANT INSERT, SELECT on region to copyuser;\n")
-    out, err = c.communicate()
-    sys.stdout.write(out)
-    sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
+from MonetDBtesting.sqltest import SQLTestCase
+
+with SQLTestCase() as tc:
+    tc.connect(username="monetdb", password="monetdb")
+    tc.execute("CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL, R_NAME 
CHAR(25) NOT NULL, R_COMMENT VARCHAR(152));\n").assertSucceeded()
+    tc.execute("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS '|', 
E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
+    tc.execute("select count(*) from region;\n")
+    tc.execute("CREATE USER copyuser WITH PASSWORD 'copyuser' name 'copyuser' 
schema sys;\n")
+    tc.execute("GRANT INSERT, SELECT on region to copyuser;\n")
+
+    tc.connect(username="copyuser", password="copyuser")
+    tc.execute("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS '|', 
E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl')).assertFailed()
+    tc.execute("select count(*) from region;\n").assertSucceeded()
+
+    tc.connect(username="monetdb", password="monetdb")
+    tc.execute("GRANT COPY FROM, COPY INTO to copyuser;\n").assertSucceeded()
 
-with process.client('sql', user = 'copyuser', passwd = 'copyuser', stdin = 
process.PIPE, stdout = process.PIPE, stderr = process.PIPE) as c:
-    c.stdin.write("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS '|', 
E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
-    c.stdin.write("select count(*) from region;\n")
-    out, err = c.communicate()
-    sys.stdout.write(out)
-    sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
+    tc.connect(username="copyuser", password="copyuser")
+    tc.execute("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS '|', 
E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl')).assertSucceeded()
+    tc.execute("select count(*) from region;\n").assertSucceeded()
+
+    tc.connect(username="monetdb", password="monetdb")
+    tc.execute("REVOKE COPY FROM, COPY INTO from 
copyuser;\n").assertSucceeded()
+
+
+
+# import os, sys
+# try:
+#     from MonetDBtesting import process
+# except ImportError:
+#     import process
+
+# TSTSRCBASE = os.environ['TSTSRCBASE']
+# SRCDIR = os.path.join(TSTSRCBASE, "sql", "benchmarks", "tpch")
+# DATADIR = os.path.join(SRCDIR,"SF-0.01")
 
-with process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr 
= process.PIPE) as c:
-    c.stdin.write("GRANT COPY FROM, COPY INTO to copyuser;\n")
-    out, err = c.communicate()
-    sys.stdout.write(out)
-    sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
+# with process.client('sql', stdin = process.PIPE, stdout = process.PIPE, 
stderr = process.PIPE) as c:
+#     c.stdin.write("CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL, 
R_NAME CHAR(25) NOT NULL, R_COMMENT VARCHAR(152));\n")
+#     c.stdin.write("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS 
'|', E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
+#     c.stdin.write("select count(*) from region;\n")
+#     c.stdin.write("CREATE USER copyuser WITH PASSWORD 'copyuser' name 
'copyuser' schema sys;\n")
+#     c.stdin.write("GRANT INSERT, SELECT on region to copyuser;\n")
+#     out, err = c.communicate()
+#     sys.stdout.write(out)
+#     sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
+
+# with process.client('sql', user = 'copyuser', passwd = 'copyuser', stdin = 
process.PIPE, stdout = process.PIPE, stderr = process.PIPE) as c:
+#     c.stdin.write("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS 
'|', E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
+#     c.stdin.write("select count(*) from region;\n")
+#     out, err = c.communicate()
+#     sys.stdout.write(out)
+#     sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
 
-with process.client('sql', user = 'copyuser', passwd = 'copyuser', stdin = 
process.PIPE, stdout = process.PIPE, stderr = process.PIPE) as c:
-    c.stdin.write("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS '|', 
E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
-    c.stdin.write("select count(*) from region;\n")
-    out, err = c.communicate()
-    sys.stdout.write(out)
-    sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
+# with process.client('sql', stdin = process.PIPE, stdout = process.PIPE, 
stderr = process.PIPE) as c:
+#     c.stdin.write("GRANT COPY FROM, COPY INTO to copyuser;\n")
+#     out, err = c.communicate()
+#     sys.stdout.write(out)
+#     sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
 
-with process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr 
= process.PIPE) as c:
-    c.stdin.write("REVOKE COPY FROM, COPY INTO from copyuser;\n")
-    out, err = c.communicate()
-    sys.stdout.write(out)
-    sys.stderr.write(err)
+# with process.client('sql', user = 'copyuser', passwd = 'copyuser', stdin = 
process.PIPE, stdout = process.PIPE, stderr = process.PIPE) as c:
+#     c.stdin.write("COPY 5 RECORDS INTO region from r'%s' USING DELIMITERS 
'|', E'|\\n';\n" % os.path.join(DATADIR, 'region.tbl'))
+#     c.stdin.write("select count(*) from region;\n")
+#     out, err = c.communicate()
+#     sys.stdout.write(out)
+#     sys.stderr.write(err.replace(DATADIR, 
'$DATADIR').replace(DATADIR.replace('\\', r'\\'), '$DATADIR').replace(r'DIR\\', 
'DIR/').replace('DIR\\', 'DIR/'))
+
+# with process.client('sql', stdin = process.PIPE, stdout = process.PIPE, 
stderr = process.PIPE) as c:
+#     c.stdin.write("REVOKE COPY FROM, COPY INTO from copyuser;\n")
+#     out, err = c.communicate()
+#     sys.stdout.write(out)
+#     sys.stderr.write(err)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to