Tests#
Note
The below checks require manifest.json to be present.
Checks related to model test coverage and test configuration.
Functions:
| Name | Description |
|---|---|
check_model_has_unique_test |
Models must have a test for uniqueness of a column. |
check_model_has_unit_tests |
Models must have more than the specified number of unit tests. |
check_model_test_coverage |
Set the minimum percentage of models that have at least one test. |
check_model_has_unique_test
#
Models must have a test for uniqueness of a column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
accepted_uniqueness_tests
|
list[str] | None
|
List of tests that are accepted as uniqueness tests. |
['dbt_expectations.expect_compound_columns_to_be_unique', 'dbt_utils.unique_combination_of_columns', 'unique']
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
model |
ModelNode
|
The ModelNode object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
manifest_checks:
# Example of allowing a custom uniqueness test
- name: check_model_has_unique_test
accepted_uniqueness_tests:
- dbt_expectations.expect_compound_columns_to_be_unique # i.e. tests from packages must include package name
- my_custom_uniqueness_test
- unique
Source code in src/dbt_bouncer/checks/manifest/models/tests.py
check_model_has_unit_tests
#
Models must have more than the specified number of unit tests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_number_of_unit_tests
|
int | None
|
The minimum number of unit tests that a model must have. |
1
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
manifest_obj |
ManifestObject
|
The ManifestObject object parsed from |
model |
ModelNode
|
The ModelNode object to check. |
unit_tests |
list[UnitTests]
|
List of UnitTests objects parsed from |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Warning
This check is only supported for dbt 1.8.0 and above.
Example(s):
Source code in src/dbt_bouncer/checks/manifest/models/tests.py
check_model_test_coverage
#
Set the minimum percentage of models that have at least one test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_model_test_coverage_pct
|
float
|
The minimum percentage of models that must have at least one test. |
100
|
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):