Manifest Checks: Unit Tests#
Note
The below checks require manifest.json to be present.
Checks related to unit test coverage and formats.
Functions:
| Name | Description |
|---|---|
check_unit_test_coverage |
Set the minimum percentage of models that have a unit test. |
check_unit_test_expect_format |
Unit tests can only use the specified formats. |
check_unit_test_given_formats |
Unit tests can only use the specified formats. |
check_unit_test_coverage
#
Set the minimum percentage of models that have a unit test.
Warning
This check is only supported for dbt 1.8.0 and above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_unit_test_coverage_pct
|
float
|
The minimum percentage of models that must have a unit test. |
100
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
models |
list[ModelNode]
|
List of ModelNode objects parsed from |
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. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
Source code in src/dbt_bouncer/checks/manifest/check_unit_tests.py
check_unit_test_expect_format
#
Unit tests can only use the specified formats.
Warning
This check is only supported for dbt 1.8.0 and above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permitted_formats
|
list[Literal[csv, dict, sql]] | None
|
A list of formats that are allowed to be used for |
['csv', 'dict', 'sql']
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
manifest_obj |
ManifestObject
|
The ManifestObject object parsed from |
unit_test |
UnitTests
|
The UnitTests 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 unit test path (i.e the .yml file where the unit test is configured). Unit test paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the unit test path (i.e the .yml file where the unit test is configured). Only unit test paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
Source code in src/dbt_bouncer/checks/manifest/check_unit_tests.py
check_unit_test_given_formats
#
Unit tests can only use the specified formats.
Warning
This check is only supported for dbt 1.8.0 and above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permitted_formats
|
list[Literal[csv, dict, sql]] | None
|
A list of formats that are allowed to be used for |
['csv', 'dict', 'sql']
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
manifest_obj |
ManifestObject
|
The ManifestObject object parsed from |
unit_test |
UnitTests
|
The UnitTests 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 unit test path (i.e the .yml file where the unit test is configured). Unit test paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the unit test path (i.e the .yml file where the unit test is configured). Only unit test paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):