@@ -51,6 +51,16 @@ def layerUri(self, conn, schema_name, table_name):
51
51
52
52
return conn .tableUri (schema_name , table_name )
53
53
54
+ def schemaName (self ):
55
+ """Providers may override (Oracle?)"""
56
+
57
+ return 'test_styles_schema'
58
+
59
+ def tableName (self ):
60
+ """Providers may override (Oracle?)"""
61
+
62
+ return 'test_styles_table'
63
+
54
64
def testMultipleStyles (self ):
55
65
56
66
md = QgsProviderRegistry .instance ().providerMetadata (self .providerKey )
@@ -65,7 +75,7 @@ def testMultipleStyles(self):
65
75
and capabilities & QgsAbstractDatabaseProviderConnection .Schemas
66
76
and capabilities & QgsAbstractDatabaseProviderConnection .DropSchema ):
67
77
68
- schema = 'testStyles'
78
+ schema = self . schemaName ()
69
79
# Start clean
70
80
if schema in conn .schemas ():
71
81
conn .dropSchema (schema , True )
@@ -75,15 +85,32 @@ def testMultipleStyles(self):
75
85
schemas = conn .schemas ()
76
86
self .assertTrue (schema in schemas )
77
87
88
+ elif (capabilities & QgsAbstractDatabaseProviderConnection .Schemas ):
89
+ schema = self .schemaName ()
90
+
91
+ try :
92
+ conn .dropVectorTable (schema , self .tableName ())
93
+ except :
94
+ pass
95
+
96
+ try :
97
+ conn .createSchema (schema )
98
+ except :
99
+ pass
100
+
101
+ schemas = conn .schemas ()
102
+ self .assertTrue (schema in schemas )
103
+
78
104
fields = QgsFields ()
79
105
fields .append (QgsField ("string_t" , QVariant .String ))
80
106
options = {}
81
107
crs = QgsCoordinateReferenceSystem .fromEpsgId (4326 )
82
108
typ = QgsWkbTypes .Point
83
109
84
110
# Create table
85
- conn .createVectorTable (schema , 'test_styles' , fields , typ , crs , True , options )
86
- uri = self .layerUri (conn , schema , 'test_styles' )
111
+ conn .createVectorTable (schema , self .tableName (), fields , typ , crs , True , options )
112
+
113
+ uri = self .layerUri (conn , schema , self .tableName ())
87
114
88
115
vl = QgsVectorLayer (uri , 'vl' , self .providerKey )
89
116
self .assertTrue (vl .isValid ())
0 commit comments