[RM- 4575] RE_SQL for Schema

Vishal Sawale <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CADTPKNnSJToQ1qdqB_R7p-1FUoU2N7tYudF-RGtp=duMC--vPg@mail.gmail.com>
Hi Hackers,

PFA the patch for RE-SQL test cases for Schema node. Please review.

Regards,
Vishal
Schema_4575.patch (application/octet-stream, 7.1 KB)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/alter_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/alter_schema.sql
new file mode 100644
index 0000000..22eb0a0
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/alter_schema.sql
@@ -0,0 +1,26 @@
+-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
+
+-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+
+CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+    AUTHORIZATION enterprisedb;
+
+COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+    IS 'test_comment';
+
+GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT ALL ON TABLES TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT ALL ON TABLES TO PUBLIC;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT ALL ON SEQUENCES TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT EXECUTE ON FUNCTIONS TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT USAGE ON TYPES TO enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/create_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/create_schema.sql
new file mode 100644
index 0000000..71ba6a5
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/create_schema.sql
@@ -0,0 +1,23 @@
+-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
+
+-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+
+CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+    AUTHORIZATION enterprisedb;
+
+COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+    IS 'test_comment';
+
+GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT ALL ON TABLES TO PUBLIC;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT ALL ON SEQUENCES TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT EXECUTE ON FUNCTIONS TO enterprisedb;
+
+ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+GRANT USAGE ON TYPES TO enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/test.json
new file mode 100644
index 0000000..5e0c9dc
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/default/9.2_plus/test.json
@@ -0,0 +1,160 @@
+{
+  "scenarios": [
+    {
+      "type": "create",
+      "name": "Create Schema",
+      "endpoint": "NODE-schema.obj",
+      "sql_endpoint": "NODE-schema.sql_id",
+      "data": {
+	"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#",
+	"namespaceowner": "enterprisedb",
+	"description": "test_comment",
+	"nspacl": [{
+		"grantee": "enterprisedb",
+		"grantor": "enterprisedb",
+		"privileges": [{
+			"privilege_type": "C",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "U",
+			"privilege": true,
+			"with_grant": false
+		}]
+	}],
+	"seclabels": [],
+	"deftblacl": [{
+		"grantee": "PUBLIC",
+		"grantor": "enterprisedb",
+		"privileges": [{
+			"privilege_type": "a",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "r",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "w",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "d",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "D",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "x",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "t",
+			"privilege": true,
+			"with_grant": false
+		}]
+	}],
+	"defseqacl": [{
+		"grantee": "enterprisedb",
+		"grantor": "enterprisedb",
+		"privileges": [{
+			"privilege_type": "r",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "w",
+			"privilege": true,
+			"with_grant": false
+		}, {
+			"privilege_type": "U",
+			"privilege": true,
+			"with_grant": false
+		}]
+	}],
+	"deffuncacl": [{
+		"grantee": "enterprisedb",
+		"grantor": "enterprisedb",
+		"privileges": [{
+			"privilege_type": "X",
+			"privilege": true,
+			"with_grant": false
+		}]
+	}],
+	"deftypeacl": [{
+		"grantee": "enterprisedb",
+		"grantor": "enterprisedb",
+		"privileges": [{
+			"privilege_type": "U",
+			"privilege": true,
+			"with_grant": false
+		}]
+	}]
+},
+      "expected_sql_file": "create_schema.sql"
+    },
+    {
+      "type": "alter",
+      "name": "Alter Schema",
+      "endpoint": "NODE-schema.obj_id",
+      "sql_endpoint": "NODE-schema.sql_id",
+          "data": {
+	"oid": 40970,
+	"description": "test_comment",
+	"nspacl": {
+		"changed": [{
+			"grantee": "enterprisedb",
+			"grantor": "enterprisedb",
+			"privileges": [{
+				"privilege_type": "U",
+				"privilege": true,
+				"with_grant": false
+			}]
+		}]
+	},
+	"deftblacl": {
+		"changed": [{
+			"grantee": "enterprisedb",
+			"grantor": "enterprisedb",
+			"privileges": [{
+				"privilege_type": "d",
+				"privilege": true,
+				"with_grant": false
+			}, {
+				"privilege_type": "w",
+				"privilege": true,
+				"with_grant": false
+			}, {
+				"privilege_type": "r",
+				"privilege": true,
+				"with_grant": false
+			}, {
+				"privilege_type": "t",
+				"privilege": true,
+				"with_grant": false
+			}, {
+				"privilege_type": "a",
+				"privilege": true,
+				"with_grant": false
+			}, {
+				"privilege_type": "x",
+				"privilege": true,
+				"with_grant": false
+			}, {
+				"privilege_type": "D",
+				"privilege": true,
+				"with_grant": false
+			}]
+		}]
+	}
+},
+      "expected_sql_file": "alter_schema.sql"
+    }
+
+
+
+  ]
+}
+
+
diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py
index 8d8fd38..7de815f 100644
--- a/web/regression/re_sql/tests/test_resql.py
+++ b/web/regression/re_sql/tests/test_resql.py
@@ -196,7 +196,6 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
 
             if 'type' in scenario and scenario['type'] == 'create':
                 # Get the url and create the specific node.
-
                 if 'data' in scenario and 'schema' in scenario['data']:
                     # If schema is already exist then fetch the oid
                     self.get_db_connection()
@@ -240,6 +239,10 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
                 if 'store_table_id' in scenario:
                     self.table_id = object_id
 
+                # Update schema id for Schema node test cases
+                if "NODE-schema.obj" in scenario["endpoint"]:
+                    self.schema_id = object_id
+
                 # Compare the reverse engineering SQL
                 if not self.check_re_sql(scenario, object_id):
                     print(scenario['name'] + "... FAIL")
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.