|
17 | 17 | import pytest |
18 | 18 |
|
19 | 19 | from dbt.tests.adapter.caching.test_caching import ( |
| 20 | + BaseCachingTest, |
20 | 21 | BaseCachingLowercaseModel, |
21 | 22 | BaseCachingUppercaseModel, |
22 | 23 | BaseCachingSelectedSchemaOnly, |
23 | 24 | ) |
| 25 | +from dbt.tests.util import run_dbt |
24 | 26 |
|
25 | 27 | model_sql = """ |
26 | 28 | {{ |
|
42 | 44 | """ |
43 | 45 |
|
44 | 46 |
|
45 | | -class TestCachingLowerCaseModel(BaseCachingLowercaseModel): |
| 47 | +class OracleBaseCaching(BaseCachingTest): |
| 48 | + |
| 49 | + def run_and_inspect_cache(self, project, run_args=None): |
| 50 | + run_dbt(run_args) |
| 51 | + |
| 52 | + # the cache was empty at the start of the run. |
| 53 | + # the model materialization returned an unquoted relation and added to the cache. |
| 54 | + adapter = project.adapter |
| 55 | + assert len(adapter.cache.relations) == 1 |
| 56 | + relation = list(adapter.cache.relations).pop() |
| 57 | + # assert relation.schema == project.test_schema |
| 58 | + assert relation.schema == project.test_schema.lower() |
| 59 | + |
| 60 | + # on the second run, dbt will find a relation in the database during cache population. |
| 61 | + # this relation will be quoted, because list_relations_without_caching (by default) uses |
| 62 | + # quote_policy = {"database": True, "schema": True, "identifier": True} |
| 63 | + # when adding relations to the cache. |
| 64 | + run_dbt(run_args) |
| 65 | + adapter = project.adapter |
| 66 | + assert len(adapter.cache.relations) == 1 |
| 67 | + second_relation = list(adapter.cache.relations).pop() |
| 68 | + |
| 69 | + # perform a case-insensitive + quote-insensitive comparison |
| 70 | + for key in ["database", "schema", "identifier"]: |
| 71 | + assert getattr(relation, key).lower() == getattr(second_relation, key).lower() |
| 72 | + |
| 73 | + |
| 74 | +class TestCachingLowerCaseModel(OracleBaseCaching): |
46 | 75 |
|
47 | 76 | @pytest.fixture(scope="class") |
48 | 77 | def models(self): |
|
0 commit comments