-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for dupe exposures and dupe model/exposure name
- Loading branch information
Kyle Wigley
committed
Jan 13, 2021
1 parent
d82a07c
commit c14e6f4
Showing
8 changed files
with
72 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/integration/025_duplicate_model_test/models-exposure-dupes/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
exposures: | ||
- name: something | ||
type: dashboard | ||
owner: | ||
email: [email protected] | ||
- name: something | ||
type: dashboard | ||
owner: | ||
email: [email protected] |
9 changes: 9 additions & 0 deletions
9
test/integration/025_duplicate_model_test/models-naming-dupes/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
models: | ||
- name: something | ||
description: This table has basic information about orders, as well as some derived facts based on payments | ||
exposures: | ||
- name: something | ||
type: dashboard | ||
owner: | ||
email: [email protected] |
24 changes: 24 additions & 0 deletions
24
test/integration/025_duplicate_model_test/test_duplicate_exposure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from dbt.exceptions import CompilationException | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
|
||
|
||
class TestDuplicateExposure(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "duplicate_exposure_025" | ||
|
||
@property | ||
def models(self): | ||
return "models-exposure-dupes" | ||
|
||
@use_profile("postgres") | ||
def test_postgres_duplicate_exposure(self): | ||
# message = "dbt found two resources with the name" | ||
try: | ||
self.run_dbt(["compile"]) | ||
self.assertTrue(False, "dbt did not throw for duplicate exposures") | ||
except CompilationException as e: | ||
pass | ||
# self.assertTrue(message in str( | ||
# e), "dbt did not throw the correct error message") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/integration/025_duplicate_model_test/test_duplicate_resource.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from dbt.exceptions import CompilationException | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
|
||
|
||
class TestDuplicateSchemaResource(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "duplicate_resource_025" | ||
|
||
@property | ||
def models(self): | ||
return "models-naming-dupes-1" | ||
|
||
@use_profile("postgres") | ||
def test_postgres_duplicate_model_and_exposure(self): | ||
try: | ||
self.run_dbt(["compile"]) | ||
except CompilationException: | ||
self.fail("Compilation Exception raised on model and " | ||
"exposure with the same name") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,7 +579,6 @@ class TestUnparsedExposure(ContractTestCase): | |
|
||
def get_ok_dict(self): | ||
return { | ||
'yaml_key': 'exposures', | ||
'name': 'my_exposure', | ||
'type': 'dashboard', | ||
'owner': { | ||
|
@@ -592,22 +591,17 @@ def get_ok_dict(self): | |
'ref("my_model")', | ||
'source("raw", "source_table")', | ||
], | ||
'original_file_path': '/some/fake/path', | ||
'package_name': 'test' | ||
} | ||
|
||
def test_ok(self): | ||
exposure = self.ContractType( | ||
yaml_key='exposures', | ||
name='my_exposure', | ||
type=ExposureType.Dashboard, | ||
owner=ExposureOwner(email='[email protected]'), | ||
maturity=MaturityType.Medium, | ||
url='https://example.com/dashboards/1', | ||
description='A exposure', | ||
depends_on=['ref("my_model")', 'source("raw", "source_table")'], | ||
original_file_path='/some/fake/path', | ||
package_name='test' | ||
) | ||
dct = self.get_ok_dict() | ||
self.assert_symmetric(exposure, dct) | ||
|