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

refactor post deploy hooks to use sql facade and clean up tests with factories #1804

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-mchok
Copy link
Collaborator

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

  • refactor post deploy hooks to use sql facade
    • this has the desired side effect of also reporting all ProgrammingErrors as UserScriptErrors instead
  • clean up tests with factories

@sfc-gh-mchok sfc-gh-mchok requested review from a team as code owners October 25, 2024 20:31
@sfc-gh-mchok sfc-gh-mchok self-assigned this Oct 25, 2024
Comment on lines +645 to +646
if run_post_deploy_hooks:
self.execute_post_deploy_hooks()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since this will be calling use_role through the sql facade, we don't need to nest it inside the above context manager

@mock.patch(MOCK_CONNECTION_DB, new_callable=mock.PropertyMock)
@mock.patch(MOCK_CONNECTION_WH, new_callable=mock.PropertyMock)
@mock.patch.dict(os.environ, {"USER": "test_user"})
def test_sql_scripts_with_no_warehouse_no_database(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I decided to pass the role/warehouse to the sql facade in execute_post_deploy_hooks so that it wasn't dependent on previous calls to use_role/warehouse by the executor, which makes this test invalid with the new setup

Comment on lines +567 to +570
app_role = (model.meta and model.meta.role) or workspace_ctx.default_role
app_warehouse = (
model.meta and model.meta.warehouse
) or workspace_ctx.default_warehouse
Copy link
Contributor

Choose a reason for hiding this comment

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

you should rebase on top of Frank's latest work (expect conflicts though, but it will make your job easier overall)

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

Successfully merging this pull request may close these issues.

2 participants