Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 63fff1c

Browse files
committed
add test case for --json --stats
1 parent 5ea6738 commit 63fff1c

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

tests/test_format.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,83 @@ def test_jsonify_diff(self):
9595
},
9696
)
9797

98+
def test_jsonify_no_stats(self):
99+
diff = DiffResultWrapper(
100+
info_tree=InfoTree(
101+
info=SegmentInfo(
102+
tables=[
103+
TableSegment(table_path=("db", "schema", "table1"), key_columns=("id",), database=Database()),
104+
TableSegment(table_path=("db", "schema", "table2"), key_columns=("id",), database=Database()),
105+
],
106+
diff_schema=(
107+
("is_exclusive_a", bool),
108+
("is_exclusive_b", bool),
109+
("is_diff_id", int),
110+
("is_diff_value", int),
111+
("id_a", str),
112+
("id_b", str),
113+
("value_a", str),
114+
("value_b", str),
115+
),
116+
diff=[
117+
(False, False, 0, 1, "1", "1", "3", "201"),
118+
(True, False, 1, 1, "2", None, "4", None),
119+
(False, True, 1, 1, None, "3", None, "202"),
120+
],
121+
)
122+
),
123+
diff=[],
124+
stats={},
125+
)
126+
json_diff = jsonify(
127+
diff,
128+
dbt_model="my_model",
129+
dataset1_columns=[
130+
("id", "NUMBER", Integer()),
131+
("value", "NUMBER", Integer()),
132+
],
133+
dataset2_columns=[
134+
("id", "NUMBER", Integer()),
135+
("value", "NUMBER", Integer()),
136+
],
137+
columns_diff={
138+
"added": [],
139+
"removed": [],
140+
"typeChanged": [],
141+
},
142+
stats_only=True
143+
)
144+
145+
self.assertEqual(
146+
json_diff,
147+
{
148+
"version": "1.1.0",
149+
"status": "success",
150+
"result": "different",
151+
"model": "my_model",
152+
"dataset1": ["db", "schema", "table1"],
153+
"dataset2": ["db", "schema", "table2"],
154+
"rows": None,
155+
"columns": {
156+
"dataset1": [
157+
{"name": "id", "type": "NUMBER", "kind": "integer"},
158+
{"name": "value", "type": "NUMBER", "kind": "integer"},
159+
],
160+
"dataset2": [
161+
{"name": "id", "type": "NUMBER", "kind": "integer"},
162+
{"name": "value", "type": "NUMBER", "kind": "integer"},
163+
],
164+
"primaryKey": ["id"],
165+
"exclusive": {
166+
"dataset1": [],
167+
"dataset2": [],
168+
},
169+
"typeChanged": [],
170+
},
171+
"summary": None,
172+
},
173+
)
174+
98175
def test_jsonify_diff_no_difeference(self):
99176
diff = DiffResultWrapper(
100177
info_tree=InfoTree(

0 commit comments

Comments
 (0)