Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check source has tests by group #91

Conversation

ashleemtib
Copy link

@ashleemtib ashleemtib commented Jan 31, 2023

Solution for issue: #75

Added check_source_has_tests_by_group.py for a new hook that checks if a source has one or more tests within a test group. This hook enables searching of multiple types of tests on sources using OR logic, where any of the tests configured in the .yaml will cause the pre-commit check to pass.

This can be configured in the .pre-commit-config.yaml like so:

    - id: check-source-has-tests-by-group
      args: ["--manifest", "dbt/target/manifest.json", "--tests", "unique", "unique_where", "unique_combination_of_columns", "--test-cnt", "1", "--"]
      name: check-source-has-tests-by-group
      verbose: true    

We tested this by running pre-commit run check-source-has-tests-by-group on a source with no uniqueness tests which proved failures, and then added a unique combination of columns test to the same source to prove passing.

@ashleemtib
Copy link
Author

Currently unsure how to interpret the pytest failures.

@eve-johns
Copy link
Contributor

I think we need to also write a test file for this.

@ashleemtib
Copy link
Author

Hi @ssassi, could you help us move this one along?

@ssassi
Copy link
Collaborator

ssassi commented Feb 6, 2023

Thanks @ashleemtib. @BAntonellini will take a look.

@BAntonellini BAntonellini merged commit dd74d50 into dbt-checkpoint:main Feb 8, 2023
Copy link
Collaborator

@BAntonellini BAntonellini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been testing locally using different PASS and FAIL expectancies, and everything is correct

@katieclaiborne katieclaiborne deleted the add-check-source-has-tests-by-group branch February 8, 2023 21:08
@katieclaiborne
Copy link
Contributor

Thanks, Bruno and Sebastián!

Are you all planning to cut a new release for the package any time soon? We're updating the rev: key in our repository's .pre-commit-config.yaml file to point to this commit, but would love to have a stable tag to point to instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants