-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SQUASH] With column level source origin
- Loading branch information
erikzaadi
committed
Sep 14, 2023
1 parent
b755b67
commit aa7f9d7
Showing
3 changed files
with
82 additions
and
126 deletions.
There are no files selected for viewing
147 changes: 47 additions & 100 deletions
147
integration_tests/tests/test_exposure_schema_validity.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 |
---|---|---|
@@ -1,161 +1,108 @@ | ||
from datetime import date, timedelta | ||
from typing import Any, Dict, List | ||
|
||
from data_generator import DATE_FORMAT, generate_dates | ||
from dbt_project import DbtProject | ||
|
||
DBT_TEST_NAME = "elementary.exposure_schema_validity" | ||
|
||
|
||
def test_expose_schema_validity_with_no_exposures(test_id: str, dbt_project: DbtProject): | ||
def test_expose_schema_validity_with_no_exposures( | ||
test_id: str, dbt_project: DbtProject | ||
): | ||
test_result = dbt_project.test(test_id, DBT_TEST_NAME, as_model=True) | ||
assert test_result["status"] == "pass" | ||
|
||
def test_expose_schema_validity_with_correct_columns_and_types(test_id: str, dbt_project: DbtProject): | ||
|
||
def test_expose_schema_validity_with_correct_columns_and_types( | ||
test_id: str, dbt_project: DbtProject | ||
): | ||
DBT_TEST_ARGS = { | ||
"node": "models.exposures_test", | ||
"columns": [ | ||
{ | ||
"name": "order_id", | ||
"dtype": "string" | ||
} | ||
], | ||
"columns": [{"name": "order_id", "dtype": "string"}], | ||
"exposures": { | ||
"ZOMG": { | ||
"meta": { | ||
"columns": [{ | ||
"name": "order_id", | ||
"data_type": "string" | ||
}] | ||
}, | ||
"meta": {"columns": [{"name": "order_id", "data_type": "string"}]}, | ||
"url": "http://bla.com", | ||
"name": "ZOMG", | ||
"depends_on": { | ||
"nodes": ['models.exposures_test'] | ||
} | ||
"depends_on": {"nodes": ["models.exposures_test"]}, | ||
} | ||
} | ||
}, | ||
} | ||
test_result = dbt_project.test( | ||
test_id, | ||
DBT_TEST_NAME, | ||
DBT_TEST_ARGS, | ||
columns=[dict( | ||
name="bla" | ||
)], | ||
as_model=True | ||
test_id, DBT_TEST_NAME, DBT_TEST_ARGS, columns=[dict(name="bla")], as_model=True | ||
) | ||
assert test_result["status"] == "pass" | ||
|
||
def test_expose_schema_validity_with_correct_columns_and_invalid_type(test_id: str, dbt_project: DbtProject): | ||
|
||
def test_expose_schema_validity_with_correct_columns_and_invalid_type( | ||
test_id: str, dbt_project: DbtProject | ||
): | ||
DBT_TEST_ARGS = { | ||
"node": "models.exposures_test", | ||
"columns": [ | ||
{ | ||
"name": "order_id", | ||
"dtype": "numeric" | ||
} | ||
], | ||
"columns": [{"name": "order_id", "dtype": "numeric"}], | ||
"exposures": { | ||
"ZOMG": { | ||
"meta": { | ||
"columns": [{ | ||
"name": "order_id", | ||
"data_type": "string" | ||
}] | ||
}, | ||
"meta": {"columns": [{"name": "order_id", "data_type": "string"}]}, | ||
"url": "http://bla.com", | ||
"name": "ZOMG", | ||
"depends_on": { | ||
"nodes": ['models.exposures_test'] | ||
} | ||
"depends_on": {"nodes": ["models.exposures_test"]}, | ||
} | ||
} | ||
}, | ||
} | ||
test_result = dbt_project.test( | ||
test_id, | ||
DBT_TEST_NAME, | ||
DBT_TEST_ARGS, | ||
columns=[dict( | ||
name="bla" | ||
)], | ||
as_model=True | ||
test_id, DBT_TEST_NAME, DBT_TEST_ARGS, columns=[dict(name="bla")], as_model=True | ||
) | ||
|
||
assert 'different data type for the column order_id string vs numeric' in test_result['test_results_query'] | ||
assert ( | ||
"different data type for the column order_id string vs" | ||
in test_result["test_results_query"] | ||
) | ||
assert test_result["status"] == "fail" | ||
|
||
|
||
def test_expose_schema_validity_with_correct_columns_and_missing_type(test_id: str, dbt_project: DbtProject): | ||
def test_expose_schema_validity_with_correct_columns_and_missing_type( | ||
test_id: str, dbt_project: DbtProject | ||
): | ||
DBT_TEST_ARGS = { | ||
"node": "models.exposures_test", | ||
"columns": [ | ||
{ | ||
"name": "order_id", | ||
"dtype": "numeric" | ||
} | ||
], | ||
"columns": [{"name": "order_id", "dtype": "numeric"}], | ||
"exposures": { | ||
"ZOMG": { | ||
"meta": { | ||
"columns": [{ | ||
"name": "order_id", | ||
}] | ||
"columns": [ | ||
{ | ||
"name": "order_id", | ||
} | ||
] | ||
}, | ||
"url": "http://bla.com", | ||
"name": "ZOMG", | ||
"depends_on": { | ||
"nodes": ['models.exposures_test'] | ||
} | ||
"depends_on": {"nodes": ["models.exposures_test"]}, | ||
} | ||
} | ||
}, | ||
} | ||
test_result = dbt_project.test( | ||
test_id, | ||
DBT_TEST_NAME, | ||
DBT_TEST_ARGS, | ||
columns=[dict( | ||
name="bla" | ||
)], | ||
as_model=True | ||
test_id, DBT_TEST_NAME, DBT_TEST_ARGS, columns=[dict(name="bla")], as_model=True | ||
) | ||
|
||
assert test_result["status"] == "pass" | ||
|
||
def test_expose_schema_validity_with_missing_columns(test_id: str, dbt_project: DbtProject): | ||
|
||
def test_expose_schema_validity_with_missing_columns( | ||
test_id: str, dbt_project: DbtProject | ||
): | ||
DBT_TEST_ARGS = { | ||
"node": "models.exposures_test", | ||
"columns": [ | ||
{ | ||
"name": "order", | ||
"dtype": "numeric" | ||
} | ||
], | ||
"columns": [{"name": "order", "dtype": "numeric"}], | ||
"exposures": { | ||
"ZOMG": { | ||
"meta": { | ||
"columns": [{ | ||
"name": "order_id", | ||
"data_type": "string" | ||
}] | ||
}, | ||
"meta": {"columns": [{"name": "order_id", "data_type": "string"}]}, | ||
"url": "http://bla.com", | ||
"name": "ZOMG", | ||
"depends_on": { | ||
"nodes": ['models.exposures_test'] | ||
} | ||
"depends_on": {"nodes": ["models.exposures_test"]}, | ||
} | ||
} | ||
}, | ||
} | ||
test_result = dbt_project.test( | ||
test_id, | ||
DBT_TEST_NAME, | ||
DBT_TEST_ARGS, | ||
columns=[dict( | ||
name="bla" | ||
)], | ||
as_model=True | ||
test_id, DBT_TEST_NAME, DBT_TEST_ARGS, columns=[dict(name="bla")], as_model=True | ||
) | ||
|
||
assert 'order_id column missing in the model' in test_result['test_results_query'] | ||
assert "order_id column missing in the model" in test_result["test_results_query"] | ||
assert test_result["status"] == "fail" |
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