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
+
32
41
33
42
class TestAnyValueSQLServer (BaseAnyValue ):
34
- pass
43
+ @pytest .fixture (scope = "class" )
44
+ def macros (self ):
45
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
35
46
36
47
37
48
@pytest .mark .skip ("bool_or not supported in this adapter" )
38
49
class TestBoolOrSQLServer (BaseBoolOr ):
39
- pass
50
+ @pytest .fixture (scope = "class" )
51
+ def macros (self ):
52
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
40
53
41
54
42
55
class TestCastBoolToTextSQLServer (BaseCastBoolToText ):
56
+ @pytest .fixture (scope = "class" )
57
+ def macros (self ):
58
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
59
+
43
60
@pytest .fixture (scope = "class" )
44
61
def models (self ):
45
62
models__test_cast_bool_to_text_sql = """
@@ -68,50 +85,74 @@ def models(self):
68
85
69
86
70
87
class TestConcatSQLServer (BaseConcat ):
71
- pass
88
+ @pytest .fixture (scope = "class" )
89
+ def macros (self ):
90
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
72
91
73
92
74
93
class TestDateTruncSQLServer (BaseDateTrunc ):
75
- pass
94
+ @pytest .fixture (scope = "class" )
95
+ def macros (self ):
96
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
76
97
77
98
78
99
class TestHashSQLServer (BaseHash ):
79
- pass
100
+ @pytest .fixture (scope = "class" )
101
+ def macros (self ):
102
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
80
103
81
104
82
105
class TestStringLiteralSQLServer (BaseStringLiteral ):
83
- pass
106
+ @pytest .fixture (scope = "class" )
107
+ def macros (self ):
108
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
84
109
85
110
86
111
class TestSplitPartSQLServer (BaseSplitPart ):
87
- pass
112
+ @pytest .fixture (scope = "class" )
113
+ def macros (self ):
114
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
88
115
89
116
90
117
class TestDateDiffSQLServer (BaseDateDiff ):
91
- pass
118
+ @pytest .fixture (scope = "class" )
119
+ def macros (self ):
120
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
92
121
93
122
94
123
class TestEscapeSingleQuotesSQLServer (BaseEscapeSingleQuotesQuote ):
95
- pass
124
+ @pytest .fixture (scope = "class" )
125
+ def macros (self ):
126
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
96
127
97
128
98
129
class TestIntersectSQLServer (BaseIntersect ):
99
- pass
130
+ @pytest .fixture (scope = "class" )
131
+ def macros (self ):
132
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
100
133
101
134
102
135
class TestLastDaySQLServer (BaseLastDay ):
103
- pass
136
+ @pytest .fixture (scope = "class" )
137
+ def macros (self ):
138
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
104
139
105
140
106
141
class TestLengthSQLServer (BaseLength ):
107
- pass
142
+ @pytest .fixture (scope = "class" )
143
+ def macros (self ):
144
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
108
145
109
146
110
147
class TestListaggSQLServer (BaseListagg ):
111
148
# Only supported in SQL Server 2017 and later or cloud versions
112
149
# DISTINCT not supported
113
150
# limit not supported
114
151
152
+ @pytest .fixture (scope = "class" )
153
+ def macros (self ):
154
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
155
+
115
156
@pytest .fixture (scope = "class" )
116
157
def seeds (self ):
117
158
seeds__data_listagg_output_csv = """group_col,expected,version
@@ -191,14 +232,22 @@ def models(self):
191
232
192
233
193
234
class TestRightSQLServer (BaseRight ):
194
- pass
235
+ @pytest .fixture (scope = "class" )
236
+ def macros (self ):
237
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
195
238
196
239
197
240
class TestSafeCastSQLServer (BaseSafeCast ):
198
- pass
241
+ @pytest .fixture (scope = "class" )
242
+ def macros (self ):
243
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
199
244
200
245
201
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
+
202
251
@pytest .fixture (scope = "class" )
203
252
def project_config_update (self ):
204
253
return {
@@ -217,15 +266,21 @@ def project_config_update(self):
217
266
218
267
219
268
class TestExceptSQLServer (BaseExcept ):
220
- pass
269
+ @pytest .fixture (scope = "class" )
270
+ def macros (self ):
271
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
221
272
222
273
223
274
class TestPositionSQLServer (BasePosition ):
224
- pass
275
+ @pytest .fixture (scope = "class" )
276
+ def macros (self ):
277
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
225
278
226
279
227
280
class TestReplaceSQLServer (BaseReplace ):
228
- pass
281
+ @pytest .fixture (scope = "class" )
282
+ def macros (self ):
283
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
229
284
230
285
231
286
class TestCurrentTimestampSQLServer (BaseCurrentTimestampNaive ):
@@ -234,14 +289,20 @@ class TestCurrentTimestampSQLServer(BaseCurrentTimestampNaive):
234
289
235
290
@pytest .mark .skip (reason = "arrays not supported" )
236
291
class TestArrayAppendSQLServer (BaseArrayAppend ):
237
- pass
292
+ @pytest .fixture (scope = "class" )
293
+ def macros (self ):
294
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
238
295
239
296
240
297
@pytest .mark .skip (reason = "arrays not supported" )
241
298
class TestArrayConcatSQLServer (BaseArrayConcat ):
242
- pass
299
+ @pytest .fixture (scope = "class" )
300
+ def macros (self ):
301
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
243
302
244
303
245
304
@pytest .mark .skip (reason = "arrays not supported" )
246
305
class TestArrayConstructSQLServer (BaseArrayConstruct ):
247
- pass
306
+ @pytest .fixture (scope = "class" )
307
+ def macros (self ):
308
+ return {"test_assert_equal.sql" : macros__test_assert_equal_sql }
0 commit comments