29
29
from dbt .tests .adapter .utils .test_split_part import BaseSplitPart
30
30
from dbt .tests .adapter .utils .test_string_literal import BaseStringLiteral
31
31
32
- macros__test_assert_equal_sql = """
33
- {% test assert_equal(model, actual, expected) %}
34
- select * from {{ model }}
35
- where {{ actual }} != {{ expected }}
36
- or ({{ actual }} is null and {{ expected }} is not null)
37
- or ({{ expected }} is null and {{ actual }} is not null)
38
- {% endtest %}
39
- """
40
-
41
32
42
- class TestAnyValueSQLServer ( BaseAnyValue ) :
33
+ class BaseFixedMacro :
43
34
@pytest .fixture (scope = "class" )
44
35
def macros (self ):
45
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
36
+ return {
37
+ "test_assert_equal.sql" : """
38
+ {% test assert_equal(model, actual, expected) %}
39
+ select * from {{ model }}
40
+ where {{ actual }} != {{ expected }}
41
+ or ({{ actual }} is null and {{ expected }} is not null)
42
+ or ({{ expected }} is null and {{ actual }} is not null)
43
+ {% endtest %}
44
+ """
45
+ }
46
46
47
47
48
- @pytest .mark .skip ("bool_or not supported in this adapter" )
49
- class TestBoolOrSQLServer (BaseBoolOr ):
50
- @pytest .fixture (scope = "class" )
51
- def macros (self ):
52
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
48
+ class TestAnyValueSQLServer (BaseFixedMacro , BaseAnyValue ):
49
+ pass
53
50
54
51
55
- class TestCastBoolToTextSQLServer ( BaseCastBoolToText ):
56
- @ pytest . fixture ( scope = "class" )
57
- def macros ( self ):
58
- return { "test_assert_equal.sql" : macros__test_assert_equal_sql }
52
+ @ pytest . mark . skip ( "bool_or not supported in this adapter" )
53
+ class TestBoolOrSQLServer ( BaseFixedMacro , BaseBoolOr ):
54
+ pass
55
+
59
56
57
+ class TestCastBoolToTextSQLServer (BaseFixedMacro , BaseCastBoolToText ):
60
58
@pytest .fixture (scope = "class" )
61
59
def models (self ):
62
60
models__test_cast_bool_to_text_sql = """
@@ -84,75 +82,59 @@ def models(self):
84
82
}
85
83
86
84
87
- class TestConcatSQLServer (BaseConcat ):
88
- @pytest .fixture (scope = "class" )
89
- def macros (self ):
90
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
85
+ class TestConcatSQLServer (BaseFixedMacro , BaseConcat ):
86
+ pass
91
87
92
88
93
- class TestDateTruncSQLServer (BaseDateTrunc ):
94
- @pytest .fixture (scope = "class" )
95
- def macros (self ):
96
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
89
+ class TestDateTruncSQLServer (BaseFixedMacro , BaseDateTrunc ):
90
+ pass
97
91
98
92
99
- class TestHashSQLServer (BaseHash ):
100
- @pytest .fixture (scope = "class" )
101
- def macros (self ):
102
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
93
+ seeds__data_hash_csv = """input_1,output
94
+ ab,187ef4436122d1cc2f40dc2b92f0eba0
95
+ a,0cc175b9c0f1b6a831c399e269772661
96
+ 1,c4ca4238a0b923820dcc509a6f75849b
97
+ ,d41d8cd98f00b204e9800998ecf8427e"""
103
98
104
99
105
- class TestStringLiteralSQLServer ( BaseStringLiteral ):
100
+ class TestHashSQLServer ( BaseFixedMacro , BaseHash ):
106
101
@pytest .fixture (scope = "class" )
107
- def macros (self ):
108
- return {"test_assert_equal.sql " : macros__test_assert_equal_sql }
102
+ def seeds (self ):
103
+ return {"data_hash.csv " : seeds__data_hash_csv }
109
104
110
105
111
- class TestSplitPartSQLServer (BaseSplitPart ):
112
- @pytest .fixture (scope = "class" )
113
- def macros (self ):
114
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
106
+ class TestStringLiteralSQLServer (BaseFixedMacro , BaseStringLiteral ):
107
+ pass
115
108
116
109
117
- class TestDateDiffSQLServer (BaseDateDiff ):
118
- @pytest .fixture (scope = "class" )
119
- def macros (self ):
120
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
110
+ class TestSplitPartSQLServer (BaseFixedMacro , BaseSplitPart ):
111
+ pass
121
112
122
113
123
- class TestEscapeSingleQuotesSQLServer (BaseEscapeSingleQuotesQuote ):
124
- @pytest .fixture (scope = "class" )
125
- def macros (self ):
126
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
114
+ class TestDateDiffSQLServer (BaseFixedMacro , BaseDateDiff ):
115
+ pass
127
116
128
117
129
- class TestIntersectSQLServer (BaseIntersect ):
130
- @pytest .fixture (scope = "class" )
131
- def macros (self ):
132
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
118
+ class TestEscapeSingleQuotesSQLServer (BaseFixedMacro , BaseEscapeSingleQuotesQuote ):
119
+ pass
133
120
134
121
135
- class TestLastDaySQLServer (BaseLastDay ):
136
- @pytest .fixture (scope = "class" )
137
- def macros (self ):
138
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
122
+ class TestIntersectSQLServer (BaseFixedMacro , BaseIntersect ):
123
+ pass
139
124
140
125
141
- class TestLengthSQLServer (BaseLength ):
142
- @pytest .fixture (scope = "class" )
143
- def macros (self ):
144
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
126
+ class TestLastDaySQLServer (BaseFixedMacro , BaseLastDay ):
127
+ pass
128
+
129
+
130
+ class TestLengthSQLServer (BaseFixedMacro , BaseLength ):
131
+ pass
145
132
146
133
147
- class TestListaggSQLServer (BaseListagg ):
134
+ class TestListaggSQLServer (BaseFixedMacro , BaseListagg ):
148
135
# Only supported in SQL Server 2017 and later or cloud versions
149
136
# DISTINCT not supported
150
137
# limit not supported
151
-
152
- @pytest .fixture (scope = "class" )
153
- def macros (self ):
154
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
155
-
156
138
@pytest .fixture (scope = "class" )
157
139
def seeds (self ):
158
140
seeds__data_listagg_output_csv = """group_col,expected,version
@@ -231,23 +213,15 @@ def models(self):
231
213
}
232
214
233
215
234
- class TestRightSQLServer (BaseRight ):
235
- @pytest .fixture (scope = "class" )
236
- def macros (self ):
237
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
216
+ class TestRightSQLServer (BaseFixedMacro , BaseRight ):
217
+ pass
238
218
239
219
240
- class TestSafeCastSQLServer (BaseSafeCast ):
241
- @pytest .fixture (scope = "class" )
242
- def macros (self ):
243
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
244
-
220
+ class TestSafeCastSQLServer (BaseFixedMacro , BaseSafeCast ):
221
+ pass
245
222
246
- class TestDateAddSQLServer (BaseDateAdd ):
247
- @pytest .fixture (scope = "class" )
248
- def macros (self ):
249
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
250
223
224
+ class TestDateAddSQLServer (BaseFixedMacro , BaseDateAdd ):
251
225
@pytest .fixture (scope = "class" )
252
226
def project_config_update (self ):
253
227
return {
@@ -265,44 +239,32 @@ def project_config_update(self):
265
239
}
266
240
267
241
268
- class TestExceptSQLServer (BaseExcept ):
269
- @pytest .fixture (scope = "class" )
270
- def macros (self ):
271
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
242
+ class TestExceptSQLServer (BaseFixedMacro , BaseExcept ):
243
+ pass
272
244
273
245
274
- class TestPositionSQLServer (BasePosition ):
275
- @pytest .fixture (scope = "class" )
276
- def macros (self ):
277
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
246
+ class TestPositionSQLServer (BaseFixedMacro , BasePosition ):
247
+ pass
278
248
279
249
280
- class TestReplaceSQLServer (BaseReplace ):
281
- @pytest .fixture (scope = "class" )
282
- def macros (self ):
283
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
250
+ class TestReplaceSQLServer (BaseFixedMacro , BaseReplace ):
251
+ pass
284
252
285
253
286
254
class TestCurrentTimestampSQLServer (BaseCurrentTimestampNaive ):
287
255
pass
288
256
289
257
290
258
@pytest .mark .skip (reason = "arrays not supported" )
291
- class TestArrayAppendSQLServer (BaseArrayAppend ):
292
- @pytest .fixture (scope = "class" )
293
- def macros (self ):
294
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
259
+ class TestArrayAppendSQLServer (BaseFixedMacro , BaseArrayAppend ):
260
+ pass
295
261
296
262
297
- @pytest .mark .skip (reason = "arrays not supported" )
298
- class TestArrayConcatSQLServer (BaseArrayConcat ):
299
- @pytest .fixture (scope = "class" )
300
- def macros (self ):
301
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
263
+ @pytest .mark .skip (reason = "arrays not supporteTd" )
264
+ class TestArrayConcatSQLServer (BaseFixedMacro , BaseArrayConcat ):
265
+ pass
302
266
303
267
304
268
@pytest .mark .skip (reason = "arrays not supported" )
305
- class TestArrayConstructSQLServer (BaseArrayConstruct ):
306
- @pytest .fixture (scope = "class" )
307
- def macros (self ):
308
- return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
269
+ class TestArrayConstructSQLServer (BaseFixedMacro , BaseArrayConstruct ):
270
+ pass
0 commit comments