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

pytest conversion test_selection, schema_tests, fail_fast, permission #4826

Merged
merged 10 commits into from
Mar 15, 2022

Conversation

ChenyuLInx
Copy link
Contributor

@ChenyuLInx ChenyuLInx commented Mar 4, 2022

resolves #
Some test in this is fully by convert_test, by running

python convert_test.py --test_dir  ~/git/dbt-core/test/integration/066_test_selection_tests --output_dir ~/git/dbt-core/tests/functional/test_selection

then do a little bit clean up of unused import.
Some require a bit of manual work to clean up the functions, i.e. we didn't have dbt tests so people were implementing it in tests.

Description

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change

@ChenyuLInx ChenyuLInx requested a review from a team as a code owner March 4, 2022 22:49
@cla-bot cla-bot bot added the cla:yes label Mar 4, 2022
@ChenyuLInx ChenyuLInx requested review from emmyoop and gshank and removed request for a team March 4, 2022 22:49
@ChenyuLInx ChenyuLInx changed the title test_selection convert WIP: test_selection convert Mar 4, 2022
@ChenyuLInx ChenyuLInx marked this pull request as draft March 4, 2022 22:56
Copy link
Contributor Author

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

@gshank @emmyoop this is one with multiple tests, do we want to keep 1 PR for a tests or we can combine multiple into one PR?

@@ -118,16 +128,22 @@ def project_config_update():
return {}


@pytest.fixture
def model_path():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is needed in some tests that have more complex file structure

Copy link
Contributor

Choose a reason for hiding this comment

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

The model dictionaries can be nested. i.e.:
{ "my_model.sql": '....', "subdir": { "another_model.sql": "..."}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, but this is used to specify model files to use for a run. previous integration tests supported it here

Copy link
Contributor

Choose a reason for hiding this comment

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

Which tests in the old integration tests? I know that the old integration test framework did that, but it was because they had directories for multiple projects in the same test directory, and we don't need that anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one . Basically every test class has it's own models

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can refactor it to just one models artifact per class if we want to do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but we don't need that anymore. We just construct a models fixture with the right files. They did that because every test had to have a separate directory, otherwise tests would interfere with each other.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think one models fixture per class is probably better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gshank this is resolved, anything else we would like to change about this PR?

core/dbt/tests/fixtures/project.py Outdated Show resolved Hide resolved
@ChenyuLInx ChenyuLInx changed the title WIP: test_selection convert pytest conversion test_selection, schema_tests, fail_fast Mar 7, 2022
@ChenyuLInx ChenyuLInx marked this pull request as ready for review March 7, 2022 19:27
check_audit_table(project)


class TestFailFastFromConfig(TestFastFailingDuringRun):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original test did this but I am not too sure why

Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at the project config, there's an "on-run-start" config that creates the audit table at the beginning of a run, and a pre-hook that inserts into the table for every model in the project that's run. So it's looking to see how many models were run.

@gshank
Copy link
Contributor

gshank commented Mar 7, 2022

I think it's fine to combine multiple tests into one PR.

Comment on lines 163 to 165
case_sensitive_models__schema_yaml = """

"""
Copy link
Member

Choose a reason for hiding this comment

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

Is this test testing for a yml and yaml file or is this just trash from the original test we can delete? Based on the name it seems like trash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did a search and looks like there's nothing using it so I removed it as suggested

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2022

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

Just the one change and it will be good to go.

core/dbt/tests/fixtures/project.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@ChenyuLInx ChenyuLInx requested a review from gshank March 14, 2022 18:36
@emmyoop
Copy link
Member

emmyoop commented Mar 14, 2022

You need to add the Skip Changelog label to the PR to bypass the GHA since we all agreed these incremental conversions would not get CHANGELOG entries.

Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

Looks good now, once you have the Changelog thing handled.

@ChenyuLInx ChenyuLInx added the Skip Changelog Skips GHA to check for changelog file label Mar 15, 2022
@ChenyuLInx ChenyuLInx changed the title pytest conversion test_selection, schema_tests, fail_fast pytest conversion test_selection, schema_tests, fail_fast, permission Mar 15, 2022
@ChenyuLInx ChenyuLInx merged commit d1bcff8 into main Mar 15, 2022
@ChenyuLInx ChenyuLInx deleted the test_selection_pytest branch March 15, 2022 15:12
@jtcohen6 jtcohen6 mentioned this pull request Mar 24, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants