Skip to content

Commit 731be29

Browse files
committed
Fix basic tests macro for where condition to filter results
1 parent e50a488 commit 731be29

File tree

2 files changed

+84
-2
lines changed

2 files changed

+84
-2
lines changed

dbt/include/oracle/macros/schema_tests.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ with all_values as (
2121
select distinct
2222
{{ column_name }} as value_field
2323

24-
from {{ model.include(False, True, True) }}
24+
from {{ model }}
2525

2626
),
2727

@@ -53,7 +53,7 @@ select * from(
5353

5454
select * from (
5555
select count(*) as null_count
56-
from {{ model.include(False, True, True) }}
56+
from {{ model }}
5757
where {{ column_name }} is null) c where c.null_count != 0
5858

5959
{% endmacro %}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""
2+
Copyright (c) 2022, Oracle and/or its affiliates.
3+
Copyright (c) 2020, Vitor Avancini
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
"""
17+
18+
import pytest
19+
20+
from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests
21+
from dbt.tests.adapter.basic.files import (
22+
seeds_base_csv,
23+
base_view_sql,
24+
base_table_sql,
25+
schema_base_yml,
26+
)
27+
28+
generic_test_seed_yml = """
29+
version: 2
30+
models:
31+
- name: base
32+
columns:
33+
- name: id
34+
tests:
35+
- not_null:
36+
config:
37+
where: "name = 'Easton'"
38+
"""
39+
40+
generic_test_view_yml = """
41+
version: 2
42+
models:
43+
- name: view_model
44+
columns:
45+
- name: id
46+
tests:
47+
- not_null:
48+
config:
49+
where: "name = 'Easton'"
50+
"""
51+
52+
generic_test_table_yml = """
53+
version: 2
54+
models:
55+
- name: table_model
56+
columns:
57+
- name: id
58+
tests:
59+
- not_null:
60+
config:
61+
where: "name = 'Easton'"
62+
"""
63+
64+
65+
class TestGenericTestsOracle(BaseGenericTests):
66+
67+
@pytest.fixture(scope="class")
68+
def seeds(self):
69+
return {
70+
"base.csv": seeds_base_csv,
71+
"schema.yml": generic_test_seed_yml,
72+
}
73+
74+
@pytest.fixture(scope="class")
75+
def models(self):
76+
return {
77+
"view_model.sql": base_view_sql,
78+
"table_model.sql": base_table_sql,
79+
"schema.yml": schema_base_yml,
80+
"schema_view.yml": generic_test_view_yml,
81+
"schema_table.yml": generic_test_table_yml,
82+
}

0 commit comments

Comments
 (0)